:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-light: #E3F2FD;
    --accent: #2196F3;
    --white: #FFFFFF;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-500: #64748B;
    --gray-700: #334155;
    --gray-900: #0F172A;
    --success: #16A34A;
    --warning: #D97706;
    --danger: #DC2626;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(21,101,192,.06);
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--white);
    box-shadow: 0 2px 12px rgba(13,71,161,.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
}

.navbar-brand {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--white) !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand .brand-text strong {
    font-weight: 800;
}

.navbar-brand .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--white);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,.9) !important;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 500;
    transition: background .2s;
    white-space: nowrap;
}

.nav-btn:hover {
    background: rgba(255,255,255,.15);
    color: var(--white) !important;
}

.navbar-user-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: rgba(255,255,255,.75);
    margin-right: 4px;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    color: var(--white);
    flex-shrink: 0;
}

.user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Legacy navbar-nav (admin) */
.navbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.navbar-nav a {
    color: rgba(255,255,255,.9);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: .9rem;
    transition: background .2s;
}

.navbar-nav a:hover { background: rgba(255,255,255,.15); color: var(--white); }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
    width: 240px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-menu { list-style: none; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--gray-700);
    font-size: .9rem;
    border-left: 3px solid transparent;
    transition: all .2s;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}

.main-content {
    flex: 1;
    padding: 28px 32px;
    overflow-x: auto;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    color: var(--gray-900);
    font-weight: 700;
}

.page-header p {
    color: var(--gray-500);
    margin-top: 4px;
    font-size: .9rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

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

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    border-top: 3px solid var(--primary);
}

.stat-card .stat-label {
    font-size: .8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

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

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

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

.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: .875rem;
    color: var(--gray-700);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,.15);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

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

table th {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

table tr:hover td { background: var(--gray-50); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-success { background: #DCFCE7; color: var(--success); }
.badge-warning { background: #FEF3C7; color: var(--warning); }
.badge-danger { background: #FEE2E2; color: var(--danger); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: .9rem;
}

.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #BBDEFB; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }

/* Auth pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--accent) 100%);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.auth-card h2 {
    text-align: center;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 28px;
    font-size: .9rem;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: .875rem;
    color: var(--gray-500);
}

/* Landing page */
.hero {
    background: linear-gradient(135deg, var(--primary-dark), var(--accent));
    color: var(--white);
    padding: 80px 24px;
    text-align: center;
}

.hero h1 { font-size: 2.5rem; margin-bottom: 16px; }
.hero p { font-size: 1.1rem; opacity: .9; max-width: 600px; margin: 0 auto 32px; }

.typing-message {
    min-height: 1.6em;
}

.typing-cursor {
    display: inline-block;
    margin-left: 2px;
    animation: typing-blink 1s step-end infinite;
    font-weight: 300;
}

@keyframes typing-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.hero-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.hero .btn-outline {
    border-color: var(--white);
    color: var(--white);
}

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

.section { padding: 60px 24px; max-width: 1200px; margin: 0 auto; }

.section-title {
    text-align: center;
    font-size: 1.75rem;
    color: var(--primary-dark);
    margin-bottom: 40px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.products-grid-pairs {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto 48px;
}

.product-pair-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 640px) {
    .product-pair-row {
        grid-template-columns: 1fr;
    }
}

.product-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: transform .2s, box-shadow .2s;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(21,101,192,.12);
}

.product-card h3 { color: var(--primary-dark); margin-bottom: 8px; }
.product-card .price { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin: 12px 0; }
.product-card p { color: var(--gray-500); font-size: .9rem; }
.product-card p a,
#productDesc a {
    color: var(--primary);
    text-decoration: underline;
    word-break: break-all;
}

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

.feature-item {
    text-align: center;
    padding: 24px;
}

.feature-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
}

/* Affiliate product row */
.affiliate-item {
    margin-bottom: 16px;
}

.affiliate-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.affiliate-item-img {
    width: 40px;
    height: 40px;
    max-width: 40px;
    max-height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    flex-shrink: 0;
    background: var(--white);
    vertical-align: middle;
    cursor: pointer;
}

.affiliate-item-img-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    font-size: 1rem;
    cursor: default;
}

.affiliate-item .affiliate-box {
    margin-top: 8px;
    margin-bottom: 0;
}

/* Affiliate link box */
.affiliate-box {
    background: var(--primary-light);
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.affiliate-box input {
    flex: 1;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: .85rem;
    font-family: monospace;
}

.footer {
    background: var(--gray-900);
    color: var(--gray-300);
    text-align: center;
    padding: 24px;
    font-size: .875rem;
}

.footer a {
    color: inherit;
    text-decoration: none;
}

.footer a:hover {
    color: var(--gray-100);
    text-decoration: underline;
}

.text-danger { color: var(--danger); font-size: .8rem; margin-top: 4px; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Hamburger toggle */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 110;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: transform .3s, opacity .3s;
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 105;
}

@media (max-width: 768px) {
    /* Hamburger visible */
    .sidebar-toggle { display: flex; }

    /* Sidebar as drawer */
    .layout { flex-direction: column; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 110;
        transform: translateX(-100%);
        transition: transform .3s ease;
        border-right: none;
        box-shadow: 4px 0 12px rgba(0,0,0,.1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }

    .main-content { padding: 16px; }

    /* Navbar adjustments */
    .navbar-top { padding: 0 12px; height: 50px; }
    .navbar-brand { font-size: .95rem; }
    .navbar-brand .logo-icon { width: 32px; height: 32px; font-size: 12px; }
    .nav-btn { padding: 6px 10px; font-size: .8rem; }
    .nav-btn-label { display: none; }
    .user-email { display: none; }
    .navbar-user-info { margin-right: 0; }
    .user-avatar { width: 22px; height: 22px; font-size: .65rem; }
    .navbar-nav a { padding: 6px 10px; font-size: .8rem; }

    /* Stats */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.3rem; }

    /* Dashboard grid stacks */
    .dashboard-grid { grid-template-columns: 1fr; }

    /* Forms */
    .form-row { grid-template-columns: 1fr; }

    /* Tables */
    table th, table td { padding: 8px 10px; font-size: .8rem; }

    /* Hero */
    .hero h1 { font-size: 1.75rem; }
    .hero { padding: 48px 16px; }

    /* Page header */
    .page-header h1 { font-size: 1.2rem; }

    /* Affiliate box */
    .affiliate-box { flex-direction: column; align-items: stretch; }

    /* Product grid */
    .product-pair-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .navbar-nav { gap: 2px; }
    .navbar-nav a { padding: 6px 8px; font-size: .75rem; }
}
