/* ==========================================
   Clash Royale Clan War Tracker - Clã 300
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* === CSS Variables === */
:root {
    --gold: #FFD700;
    --gold-dark: #C9A800;
    --gold-light: #FFE44D;
    --dark-bg: #0a0a1a;
    --dark-card: #12122a;
    --dark-card-hover: #1a1a3a;
    --royal-blue: #1e3c82;
    --light-blue: #4682dc;
    --purple: #6c3fa0;
    --purple-dark: #4a2570;
    --green: #2ecc71;
    --green-dark: #1a9e52;
    --red: #e74c3c;
    --red-dark: #c0392b;
    --orange: #f39c12;
    --white: #ffffff;
    --text: #e0e0f0;
    --text-dim: #8888aa;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
}

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--dark-bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* === Background Effects === */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(108, 63, 160, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(30, 60, 130, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* === Top Accent Bar === */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--royal-blue), var(--gold), var(--purple));
    z-index: 1000;
}

/* === Header === */
.header {
    position: relative;
    z-index: 1;
    padding: 30px 40px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    object-fit: cover;
    border: 2px solid var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.header-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}

.header-text p {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 400;
    margin-top: 2px;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--gold);
    font-weight: 600;
}

.header-badge .dot {
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* === Main Container === */
.container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px 40px;
}

/* === Upload Zone === */
.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 20px;
    padding: 50px 40px;
    text-align: center;
    background: var(--glass);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 30px;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--gold);
    background: rgba(255, 215, 0, 0.05);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.08);
}

.upload-zone .icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.upload-zone h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
}

.upload-zone p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.upload-zone .formats {
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-dim);
    opacity: 0.7;
}

.upload-zone input[type="file"] {
    display: none;
}

/* === Loading Spinner === */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.loading.active {
    display: block;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* === Dashboard === */
.dashboard {
    display: none;
}

.dashboard.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

/* === Summary Cards === */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.summary-card {
    background: var(--dark-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: rgba(255, 255, 255, 0.12);
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
}

.summary-card.gold::before { background: linear-gradient(90deg, var(--gold), var(--gold-dark)); }
.summary-card.blue::before { background: linear-gradient(90deg, var(--light-blue), var(--royal-blue)); }
.summary-card.green::before { background: linear-gradient(90deg, var(--green), var(--green-dark)); }
.summary-card.red::before { background: linear-gradient(90deg, var(--red), var(--red-dark)); }
.summary-card.purple::before { background: linear-gradient(90deg, var(--purple), var(--purple-dark)); }
.summary-card.orange::before { background: linear-gradient(90deg, var(--orange), #e67e22); }

.summary-card .card-icon {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.summary-card .card-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--white);
    line-height: 1;
    margin-bottom: 4px;
}

.summary-card .card-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* === Action Bar === */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 20px 12px 44px;
    background: var(--dark-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.08);
}

.search-box input::placeholder {
    color: var(--text-dim);
}

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
}

.filter-btn {
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--dark-card);
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.filter-btn:hover,
.filter-btn.active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(255, 215, 0, 0.08);
}

.btn-pdf {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #1a1a2e;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.5px;
}

.btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.3);
}

.btn-pdf:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === Members Table === */
.table-container {
    background: var(--dark-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

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

.members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.members-table thead th {
    background: rgba(30, 60, 130, 0.4);
    padding: 14px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    position: sticky;
    top: 0;
    z-index: 10;
}

.members-table thead th:hover {
    color: var(--gold);
    background: rgba(30, 60, 130, 0.6);
}

.members-table thead th.sorted-asc::after {
    content: ' ▲';
    color: var(--gold);
}

.members-table thead th.sorted-desc::after {
    content: ' ▼';
    color: var(--gold);
}

.members-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: all 0.2s ease;
}

.members-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.members-table tbody tr:hover {
    background: rgba(255, 215, 0, 0.04);
}

.members-table tbody td {
    padding: 12px 12px;
    text-align: center;
    white-space: nowrap;
}

.members-table tbody td.name-cell {
    text-align: left;
    font-weight: 600;
    color: var(--white);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.members-table .rank-cell {
    font-weight: 700;
    color: var(--gold);
    font-size: 0.9rem;
}

.members-table .fame-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.fame-cell.above {
    color: var(--green);
}

.fame-cell.below {
    color: var(--red);
}

.fame-cell.zero {
    color: var(--text-dim);
    opacity: 0.4;
}

.avg-cell {
    font-weight: 700;
    font-size: 0.9rem;
}

.avg-cell.above {
    color: var(--green);
}

.avg-cell.below {
    color: var(--red);
}

/* === Status Badges === */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.good {
    background: rgba(46, 204, 113, 0.15);
    color: var(--green);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.status-badge.warning {
    background: rgba(243, 156, 18, 0.15);
    color: var(--orange);
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.status-badge.critical {
    background: rgba(231, 76, 60, 0.15);
    color: var(--red);
    border: 1px solid rgba(231, 76, 60, 0.3);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.2); }
    50% { box-shadow: 0 0 15px 3px rgba(231, 76, 60, 0.15); }
}

.status-badge.ok {
    background: rgba(70, 130, 220, 0.15);
    color: var(--light-blue);
    border: 1px solid rgba(70, 130, 220, 0.3);
}

/* === Trend Indicator === */
.trend {
    font-size: 1rem;
}

.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.trend.stable { color: var(--text-dim); }

/* === Toast Notification === */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    border-radius: 12px;
    background: var(--dark-card);
    border: 1px solid var(--border);
    color: var(--white);
    font-size: 0.9rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--green);
}

.toast.error {
    border-left: 4px solid var(--red);
}

/* === Medal Styles === */
.medal {
    font-size: 1.2rem;
}

/* === Table Footer === */
.table-footer {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* === Responsive === */
@media (max-width: 768px) {
    .header {
        padding: 20px;
        flex-direction: column;
        gap: 12px;
    }

    .container {
        padding: 0 16px 30px;
    }

    .upload-zone {
        padding: 30px 20px;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-bar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--dark-bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
