/* Logs Page - Modern Colorful Design */
/* Following UI Style Guide principles */

/* ===== Page Header ===== */
#page-logs .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

#page-logs .page-title {
    font-size: 1.875rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#page-logs .page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

#page-logs .header-actions {
    display: flex;
    gap: 10px;
}

#page-logs .header-actions .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#page-logs .header-actions .btn:hover {
    background: var(--bg-hover);
    border-color: #f59e0b;
    color: #f59e0b;
}

/* ===== Filters Row ===== */
#page-logs .log-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

#page-logs .log-filters::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f59e0b, #ef4444, #a855f7, #3b82f6);
}

#page-logs .log-filters select,
#page-logs .log-filters input[type="date"],
#page-logs .log-filters input[type="text"] {
    padding: 10px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

#page-logs .log-filters select:hover,
#page-logs .log-filters input:hover {
    border-color: var(--text-muted);
}

#page-logs .log-filters select:focus,
#page-logs .log-filters input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px #f59e0b20;
}

#page-logs .log-filters input[type="text"] {
    min-width: 200px;
}

/* ===== Logs Table Wrapper ===== */
#page-logs .logs-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

/* ===== Logs Table ===== */
#page-logs .logs-table {
    width: 100%;
    border-collapse: collapse;
}

#page-logs .logs-table thead {
    background: linear-gradient(135deg, #f59e0b10 0%, var(--bg-dark) 50%);
}

#page-logs .logs-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

#page-logs .logs-table td {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

#page-logs .logs-table tbody tr {
    transition: all 0.15s ease;
    animation: rowAppear 0.4s ease forwards;
    opacity: 0;
}

#page-logs .logs-table tbody tr:nth-child(1) { animation-delay: 0ms; }
#page-logs .logs-table tbody tr:nth-child(2) { animation-delay: 30ms; }
#page-logs .logs-table tbody tr:nth-child(3) { animation-delay: 60ms; }
#page-logs .logs-table tbody tr:nth-child(4) { animation-delay: 90ms; }
#page-logs .logs-table tbody tr:nth-child(5) { animation-delay: 120ms; }
#page-logs .logs-table tbody tr:nth-child(6) { animation-delay: 150ms; }
#page-logs .logs-table tbody tr:nth-child(7) { animation-delay: 180ms; }
#page-logs .logs-table tbody tr:nth-child(8) { animation-delay: 210ms; }
#page-logs .logs-table tbody tr:nth-child(9) { animation-delay: 240ms; }
#page-logs .logs-table tbody tr:nth-child(10) { animation-delay: 270ms; }
#page-logs .logs-table tbody tr:nth-child(n+11) { animation-delay: 300ms; }

@keyframes rowAppear {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#page-logs .logs-table tbody tr:hover {
    background: var(--bg-hover);
}

#page-logs .logs-table tbody tr:last-child td {
    border-bottom: none;
}

#page-logs .logs-table tbody tr.log-rolled-back {
    opacity: 0.5;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(239, 68, 68, 0.03) 10px,
        rgba(239, 68, 68, 0.03) 20px
    );
}

/* ===== Log Type Badges ===== */
.log-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.log-type-badge.auto {
    background: linear-gradient(135deg, #22c55e20, #22c55e10);
    color: #22c55e;
    border: 1px solid #22c55e30;
}

.log-type-badge.approval {
    background: linear-gradient(135deg, #3b82f620, #3b82f610);
    color: #3b82f6;
    border: 1px solid #3b82f630;
}

.log-type-badge.manual {
    background: linear-gradient(135deg, #a855f720, #a855f710);
    color: #a855f7;
    border: 1px solid #a855f730;
}

.log-type-badge.rollback {
    background: linear-gradient(135deg, #ef444420, #ef444410);
    color: #ef4444;
    border: 1px solid #ef444430;
}

.log-rollback-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 2px 8px;
    background: #ef444415;
    color: #ef4444;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 600;
}

/* ===== Change Details ===== */
.log-change-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-change-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}

.log-change-label {
    font-weight: 600;
    color: var(--text-muted);
    min-width: 50px;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.old-value {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.7;
}

.arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.new-value {
    font-weight: 700;
}

.new-value.increase {
    color: #22c55e;
    text-shadow: 0 0 10px #22c55e30;
}
.new-value.decrease {
    color: #ef4444;
    text-shadow: 0 0 10px #ef444430;
}

.change-pct {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.change-pct.increase {
    background: #22c55e20;
    color: #22c55e;
}

.change-pct.decrease {
    background: #ef444420;
    color: #ef4444;
}

/* ===== User Column ===== */
.log-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.log-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f630, #a855f730);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.log-user-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Reason Column ===== */
.log-reason-cell {
    max-width: 220px;
}

.log-reason {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.log-confidence {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    background: linear-gradient(135deg, #a855f720, #a855f710);
    color: #a855f7;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    border: 1px solid #a855f730;
}

/* ===== Rollback Button ===== */
.log-rollback-btn {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #ef444450;
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.log-rollback-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 15px #ef444440;
    transform: translateY(-1px);
}

/* ===== Pagination ===== */
#logs-pagination {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f59e0b08 0%, transparent 50%);
    border-top: 1px solid var(--border-color);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.pagination .btn-sm {
    padding: 8px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 500;
}

.pagination .btn-sm:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: #f59e0b50;
}

.pagination .btn-sm.btn-primary {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    border-color: #f59e0b;
    color: black;
    font-weight: 600;
    box-shadow: 0 0 15px #f59e0b30;
}

.pagination .btn-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Stats Grid ===== */
#page-logs .log-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 24px;
}

/* ===== Stat Cards ===== */
#page-logs .log-stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

#page-logs .log-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Auto - Green */
#page-logs .log-stat-card:nth-child(1) {
    border-top: 3px solid #22c55e;
}

#page-logs .log-stat-card:nth-child(1)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #22c55e10 0%, transparent 50%);
    pointer-events: none;
}

#page-logs .log-stat-card:nth-child(1) .log-stat-icon {
    background: #22c55e25;
    color: #22c55e;
    box-shadow: 0 0 20px #22c55e30;
}

#page-logs .log-stat-card:nth-child(1) .log-stat-value {
    color: #22c55e;
    text-shadow: 0 0 15px #22c55e40;
}

/* Approval - Blue */
#page-logs .log-stat-card:nth-child(2) {
    border-top: 3px solid #3b82f6;
}

#page-logs .log-stat-card:nth-child(2)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #3b82f610 0%, transparent 50%);
    pointer-events: none;
}

#page-logs .log-stat-card:nth-child(2) .log-stat-icon {
    background: #3b82f625;
    color: #3b82f6;
    box-shadow: 0 0 20px #3b82f630;
}

#page-logs .log-stat-card:nth-child(2) .log-stat-value {
    color: #3b82f6;
    text-shadow: 0 0 15px #3b82f640;
}

/* Manual - Purple */
#page-logs .log-stat-card:nth-child(3) {
    border-top: 3px solid #a855f7;
}

#page-logs .log-stat-card:nth-child(3)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #a855f710 0%, transparent 50%);
    pointer-events: none;
}

#page-logs .log-stat-card:nth-child(3) .log-stat-icon {
    background: #a855f725;
    color: #a855f7;
    box-shadow: 0 0 20px #a855f730;
}

#page-logs .log-stat-card:nth-child(3) .log-stat-value {
    color: #a855f7;
    text-shadow: 0 0 15px #a855f740;
}

/* Rollback - Red */
#page-logs .log-stat-card:nth-child(4) {
    border-top: 3px solid #ef4444;
}

#page-logs .log-stat-card:nth-child(4)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #ef444410 0%, transparent 50%);
    pointer-events: none;
}

#page-logs .log-stat-card:nth-child(4) .log-stat-icon {
    background: #ef444425;
    color: #ef4444;
    box-shadow: 0 0 20px #ef444430;
}

#page-logs .log-stat-card:nth-child(4) .log-stat-value {
    color: #ef4444;
    text-shadow: 0 0 15px #ef444440;
}

/* Stat Icon */
#page-logs .log-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#page-logs .log-stat-icon svg {
    width: 24px;
    height: 24px;
}

/* Stat Info */
#page-logs .log-stat-info {
    display: flex;
    flex-direction: column;
}

#page-logs .log-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

#page-logs .log-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ===== Empty State ===== */
#page-logs .empty-state {
    padding: 60px 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Animations ===== */
#page-logs .log-stat-card {
    animation: cardAppear 0.4s ease forwards;
    opacity: 0;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#page-logs .log-stat-card:nth-child(1) { animation-delay: 0ms; }
#page-logs .log-stat-card:nth-child(2) { animation-delay: 80ms; }
#page-logs .log-stat-card:nth-child(3) { animation-delay: 160ms; }
#page-logs .log-stat-card:nth-child(4) { animation-delay: 240ms; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    #page-logs .log-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    #page-logs .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    #page-logs .log-stats-grid {
        grid-template-columns: 1fr;
    }

    #page-logs .log-filters {
        flex-direction: column;
    }

    #page-logs .log-filters select,
    #page-logs .log-filters input {
        width: 100%;
    }

    .log-change-detail {
        font-size: 0.75rem;
    }

    #page-logs .logs-table-wrapper {
        overflow-x: auto;
    }
}
