:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --youtube-red: #ff0000;
    --meta-blue: #0668E1;
    --x-black: #000000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.1) 0px, transparent 50%);
    display: flex;
    flex-direction: column;
}

/* Glassmorphism utility */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #6366f1, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.upload-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

.card {
    padding: 2rem;
}

h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
}

.dropzone {
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 1.5rem;
}

.dropzone:hover,
.dropzone.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Platform Selectors */
.platform-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.platform-btn {
    flex: 1;
    min-width: 100px;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: rgba(30, 41, 59, 0.4);
}

.platform-btn i {
    font-size: 1.5rem;
}

.platform-btn.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
}

.platform-btn[data-platform="youtube"].active {
    border-color: var(--youtube-red);
}

.platform-btn[data-platform="meta"].active {
    border-color: var(--meta-blue);
}

.platform-btn[data-platform="x"].active {
    border-color: var(--x-black);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}

/* History List */
.history-list {
    margin-top: 1rem;
}

.history-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s ease;
}

.delete-history-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    opacity: 0;
}

.history-item:hover .delete-history-btn {
    opacity: 1;
}

.delete-history-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.history-item:last-child {
    border-bottom: none;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-published {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.status-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Progress */
.progress-container {
    margin-top: 1.5rem;
    display: none;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
}

/* Multi-platform Tabs */
.platform-tabs-nav::-webkit-scrollbar {
    height: 4px;
}

.platform-tabs-nav::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.platform-tab {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.platform-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.platform-form-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Navbar */
.main-nav {
    display: flex;
    gap: 1.5rem;
    margin: 0 2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* View Control */
.view-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view-content.active {
    display: block;
}

/* Analytics */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-info .stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--error);
}

.chart-container {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 12px;
    margin-top: 1rem;
    overflow: hidden;
}

/* ==============================
   RESPONSIVE LAYOUT
   ============================== */

/* --- Laptop / Small Desktop (≤1024px) --- */
@media (max-width: 1024px) {
    main {
        padding: 1.5rem;
    }

    .upload-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .analytics-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

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

    .platform-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }
}

/* --- Tablet (≤768px) --- */
@media (max-width: 768px) {
    main {
        padding: 1rem;
        padding-bottom: 85px;
        /* space for bottom nav */
    }

    /* Header → Bottom Navigation Bar */
    header {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0.4rem 0.75rem;
        z-index: 1000;
        border-radius: 0;
        /* remove glass corner rounding */
        border-bottom: none;
        border-top: 1px solid var(--glass-border);
        background: rgba(15, 23, 42, 0.92);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        justify-content: center;
        gap: 1rem;
    }

    header .logo {
        display: none;
    }

    header .user-profile #user-email {
        display: none;
    }

    header .user-profile {
        display: flex;
        align-items: center;
    }

    /* Nav links become icon-stacked buttons */
    .main-nav {
        display: flex;
        gap: 1.5rem;
    }

    .nav-link {
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        font-size: 0.65rem;
        padding: 0.4rem 0.6rem;
        border-bottom: none;
        /* remove desktop underline */
    }

    .nav-link.active {
        border-bottom: none;
        color: var(--primary);
    }

    .nav-link i {
        font-size: 1.15rem;
        margin: 0;
    }

    /* Grids stack */
    .upload-grid,
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Cards tighten up */
    .card {
        padding: 1.25rem;
    }

    .stat-card {
        padding: 1rem;
        gap: 1rem;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .stat-info h3 {
        font-size: 1.25rem;
    }

    /* Dropzone smaller */
    .dropzone {
        padding: 2rem 1rem;
    }

    /* Analytics header */
    .analytics-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .analytics-header h2 {
        font-size: 1.1rem;
    }

    .platform-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }

    .date-filter {
        display: flex;
        gap: 0.5rem;
    }

    /* Platform selection buttons */
    .platform-options {
        gap: 0.5rem;
    }

    .platform-btn {
        min-width: 80px;
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    .platform-btn i {
        font-size: 1.2rem;
    }

    /* Modal */
    .modal-content {
        width: 94%;
        padding: 1.25rem;
        margin: 15% auto;
    }

    /* Delete always visible on touch */
    .delete-history-btn {
        opacity: 1;
    }

    /* Buttons */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    #logout-btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.7rem;
    }

    h2 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
}

/* --- Small Phone (≤480px) --- */
@media (max-width: 480px) {
    main {
        padding: 0.75rem;
        padding-bottom: 80px;
    }

    header {
        padding: 0.35rem 0.5rem;
    }

    .main-nav {
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.6rem;
        padding: 0.3rem 0.4rem;
    }

    .nav-link i {
        font-size: 1rem;
    }

    .card {
        padding: 1rem;
        border-radius: 12px;
    }

    .stat-card {
        gap: 0.75rem;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .stat-info h3 {
        font-size: 1.1rem;
    }

    .stat-info .stat-label {
        font-size: 0.7rem;
    }

    .dropzone {
        padding: 1.5rem 0.75rem;
    }

    .platform-btn {
        min-width: 70px;
        padding: 0.6rem 0.4rem;
        font-size: 0.75rem;
        border-radius: 8px;
    }

    .platform-btn i {
        font-size: 1rem;
    }

    .history-item {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .modal-content {
        width: 96%;
        padding: 1rem;
        margin: 10% auto;
        border-radius: 12px;
    }

    .btn-primary {
        font-size: 0.85rem;
    }
}