/* ========================================
   CACHE PAGE - ESTILOS OTIMIZADOS
   ======================================== */

:root {
    --card-bg: #1e2a3f;
    --card-border: #2d3e52;
    --row-hover: #252d3d;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

body {
    min-height: 100vh;
}

.subheading {
    color: var(--muted);
    margin-top: 6px;
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

@media (max-width: 768px) {
    .header-actions {
        flex-direction: column;
    }
    
    .header-actions .btn {
        width: 100%;
    }
}

/* ========================================
   STATUS MESSAGE
   ======================================== */

.status-message {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.status-message.show {
    display: flex;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.status-message.info {
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.3);
    color: #3b82f6;
}

.status-message.success {
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.3);
    color: #22c55e;
}

.status-message.error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: #ef4444;
}

/* ========================================
   STATS GRID
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(139,92,246,0.15) 0%, rgba(59,130,246,0.1) 100%);
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139,92,246,0.2);
    border-color: rgba(139,92,246,0.5);
}

.stat-icon {
    font-size: 28px;
    color: #8b5cf6;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139,92,246,0.1);
    border-radius: 10px;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   INFO BOX
   ======================================== */

.info-box {
    background: linear-gradient(135deg, rgba(34,197,94,0.1) 0%, rgba(59,130,246,0.05) 100%);
    border: 1px solid rgba(34,197,94,0.3);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 24px;
}

.info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #22c55e;
    font-size: 15px;
}

.info-header i {
    font-size: 18px;
}

.info-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text);
}

.info-item i {
    color: #22c55e;
    font-size: 14px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* ========================================
   PROGRESS BAR
   ======================================== */

.progress-container {
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    padding: 20px;
    margin-bottom: 24px;
    animation: slideDown 0.3s ease;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.progress-title {
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.progress-title i {
    color: #f59e0b;
}

.progress-stats {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(59, 130, 246, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(59,130,246,0.3);
}

.progress-bar {
    height: 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #22c55e);
    border-radius: 6px;
    transition: width 0.5s ease;
    position: relative;
    box-shadow: 0 0 10px rgba(34,197,94,0.5);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#progress-current {
    display: flex;
    align-items: center;
    gap: 6px;
}

#progress-percent {
    font-weight: 600;
    color: #22c55e;
}

.progress-log {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
}

.log-entry {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.log-entry.info {
    background: rgba(59,130,246,0.1);
    color: #3b82f6;
}

.log-entry.success {
    background: rgba(34,197,94,0.1);
    color: #22c55e;
}

.log-entry.error {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

.log-entry.skip {
    background: rgba(234,179,8,0.1);
    color: #eab308;
}

/* ========================================
   PANEL GENÉRICO
   ======================================== */

.panel {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.panel-title i {
    font-size: 18px;
    color: #8b5cf6;
}

.panel-content {
    padding: 18px;
}

.btn-action-small {
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.3);
    color: #8b5cf6;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-action-small:hover {
    background: #8b5cf6;
    border-color: #8b5cf6;
    color: white;
    transform: scale(1.05);
}

/* ========================================
   TABELA
   ======================================== */

.table-wrapper {
    overflow-x: auto;
}

.cache-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.cache-table thead {
    background: rgba(255,255,255,0.03);
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.cache-table th {
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cache-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text);
}

.cache-table tbody tr {
    transition: all 0.2s ease;
}

.cache-table tbody tr:hover {
    background: var(--row-hover);
}

.cache-table tbody tr td:first-child {
    border-left: 3px solid transparent;
}

.cache-table tbody tr:hover td:first-child {
    border-left-color: #8b5cf6;
}

.col-status {
    width: 30px;
}

.col-name {
    min-width: 150px;
}

.col-size {
    width: 100px;
}

.col-progress {
    min-width: 250px;
}

.col-actions {
    width: 120px;
    text-align: center;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.loading i {
    font-size: 24px;
    margin-right: 8px;
}

/* ========================================
   STATUS BADGES
   ======================================== */

.server-row-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.server-name {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.server-id {
    font-size: 11px;
    color: var(--text-muted);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.cached {
    background: rgba(34,197,94,0.2);
    color: #22c55e;
    border: 1px solid rgba(34,197,94,0.4);
}

.status-badge.pending {
    background: rgba(234,179,8,0.2);
    color: #eab308;
    border: 1px solid rgba(234,179,8,0.4);
}

.status-badge.expired {
    background: rgba(239,68,68,0.2);
    color: #ef4444;
    border: 1px solid rgba(239,68,68,0.4);
}

.status-badge.refreshing {
    background: rgba(59,130,246,0.2);
    color: #3b82f6;
    border: 1px solid rgba(59,130,246,0.4);
}

.status-badge.downloading {
    background: rgba(139,92,246,0.2);
    color: #8b5cf6;
    border: 1px solid rgba(139,92,246,0.4);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ========================================
   PROGRESS CELL
   ======================================== */

.server-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.server-progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.server-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.server-progress-fill.green {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.server-progress-fill.yellow {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.server-progress-fill.red {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.server-progress-fill.empty {
    background: rgba(255,255,255,0.2);
}

.server-progress-fill.download-progress {
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    box-shadow: 0 0 8px rgba(59,130,246,0.5);
}

.server-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

.download-speed,
.download-eta,
.time-info,
.expiry-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.download-speed {
    color: #06b6d4;
}

.expiry-info.green {
    color: #22c55e;
}

.expiry-info.yellow {
    color: #f59e0b;
}

.expiry-info.red {
    color: #ef4444;
}

.downloading-active {
    background: rgba(139,92,246,0.05);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(139,92,246,0.2);
}

/* ========================================
   ACTION BUTTONS
   ======================================== */

.action-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.btn-icon {
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.3);
    color: #8b5cf6;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.btn-icon:hover {
    background: #8b5cf6;
    border-color: #8b5cf6;
    color: white;
    transform: scale(1.1);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon.delete {
    border-color: rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

.btn-icon.delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.btn-icon.refresh {
    border-color: rgba(34,197,94,0.3);
    background: rgba(34,197,94,0.1);
    color: #22c55e;
}

.btn-icon.refresh:hover {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

/* ========================================
   RESPONSIVIDADE
   ======================================== */

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .info-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .header-actions {
        flex-direction: column;
    }
    
    .header-actions .btn {
        width: 100%;
    }
    
    .cache-table {
        font-size: 12px;
    }
    
    .cache-table th,
    .cache-table td {
        padding: 10px 10px;
    }
    
    .col-size {
        width: 80px;
    }
    
    .col-progress {
        min-width: 200px;
    }
    
    .server-progress-text {
        font-size: 10px;
    }
    
    .btn-icon {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .progress-details {
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .stat-value {
        font-size: 16px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .info-content {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .info-item {
        font-size: 12px;
    }
    
    .col-progress {
        display: none;
    }
    
    .cache-table th,
    .cache-table td {
        padding: 8px 6px;
        font-size: 11px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-icon {
        width: 100%;
    }
    
    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .progress-title {
        font-size: 13px;
    }
}
