/**
 * CTV Portal - Components
 * Buttons, Cards, Badges, Forms, Login
 * Modern Glassmorphism Design
 * 
 * Updated: January 2026
 */

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS - Modern Design
   ═══════════════════════════════════════════════════════════════════ */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    color: white;
    width: 100%;
    box-shadow: 0 4px 14px rgba(79, 125, 243, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 125, 243, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.12);
}

/* ═══════════════════════════════════════════════════════════════════
   BADGES - Reference Design
   ═══════════════════════════════════════════════════════════════════ */

.badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

.user-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.user-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.user-badge.manager {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-badge.director {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-badge.leader {
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-badge.gold { 
    background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-badge.silver { 
    background: linear-gradient(135deg, #94a3b8 0%, #475569 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.user-badge.bronze { 
    background: linear-gradient(135deg, #fdba74 0%, #c2410c 100%);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Priority Badges from Reference */
.priority-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.priority-badge.low {
    background: #dcfce7;
    color: #16a34a;
}

.priority-badge.medium {
    background: #ffedd5;
    color: #ea580c;
}

.priority-badge.high {
    background: #fee2e2;
    color: #dc2626;
}

/* ═══════════════════════════════════════════════════════════════════
   FORM ELEMENTS - Modern Design
   ═══════════════════════════════════════════════════════════════════ */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 125, 243, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: all 0.2s ease;
    resize: vertical;
    min-height: 80px;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 125, 243, 0.1);
}

.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: all 0.2s ease;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    padding-right: 45px;
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234F7DF3' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    box-shadow: 0 0 0 3px rgba(79, 125, 243, 0.1);
}

.form-group input[readonly],
.form-group input:disabled {
    background: #f5f5f5 !important;
    cursor: not-allowed;
    color: var(--text-secondary);
}

.form-group input[readonly]:focus,
.form-group input:disabled:focus {
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: none;
    background: #f5f5f5 !important;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-blue);
    cursor: pointer;
    border-radius: 4px;
}

.remember-me label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   LOGIN BOX - Modern Glass Design
   ═══════════════════════════════════════════════════════════════════ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--glass-border);
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(79, 125, 243, 0.3);
}

.login-logo svg {
    width: 40px;
    height: 40px;
}

.login-logo svg path {
    stroke: #ffffff;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

.error-msg {
    color: var(--danger);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    display: none;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
}

.error-msg.show {
    display: block;
}

.back-link {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.back-link a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.back-link a:hover {
    color: var(--primary-blue);
}

/* Login Success Animation */
.login-success {
    display: none;
    text-align: center;
    padding: 20px;
}

.login-success.show {
    display: block;
}

.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: successPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.success-checkmark svg {
    width: 40px;
    height: 40px;
    stroke: white;
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: checkDraw 0.5s ease forwards 0.3s;
}

@keyframes successPop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes checkDraw {
    to { stroke-dashoffset: 0; }
}

.success-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.success-subtext {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════════
   DATE FILTER BUTTONS - Modern Design
   ═══════════════════════════════════════════════════════════════════ */

.btn-filter-preset {
    padding: 10px 20px;
    border: none;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.btn-filter-preset:hover {
    background: rgba(255, 255, 255, 0.8);
    color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.btn-filter-preset.active {
    background: #ffffff;
    color: var(--primary-blue);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

/* Red Envelope Indicator */
.btn-filter-preset.has-data::after {
    content: '🧧';
    position: absolute;
    top: -10px;
    right: -8px;
    font-size: 18px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15));
    animation: envelope-float 3s ease-in-out infinite;
    z-index: 10;
    display: block;
}

/* Float animation for the envelope */
@keyframes envelope-float {
    0%, 100% { 
        transform: translateY(0) rotate(5deg);
    }
    50% { 
        transform: translateY(-6px) rotate(-5deg);
    }
}

/* Hide the old indicator elements if they exist in DOM to avoid duplicates */
.btn-filter-preset .data-indicator {
    display: none !important;
}

.btn-filter {
    padding: 10px 24px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-purple) 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(79, 125, 243, 0.3);
}

.btn-filter:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 125, 243, 0.4);
}

.date-input {
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.date-input:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--primary-blue);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.custom-date-filter {
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.date-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

@media (max-width: 768px) {
    .btn-filter-preset {
        padding: 6px 14px;
        font-size: 12px;
    }
    
    .date-filter-row {
        gap: 6px;
    }
    
    .custom-date-filter {
        flex-direction: column;
    }
    
    .custom-date-filter > div {
        flex-direction: column;
        width: 100%;
    }
    
    .date-input {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   LIFETIME STATISTICS TABLE - Modern Design
   ═══════════════════════════════════════════════════════════════════ */

.lifetime-stats-table {
    width: 100%;
}

.stats-table {
    width: 100%;
    border-collapse: separate; /* Changed from collapse for cleaner spacing */
    border-spacing: 0 4px; /* Space between rows */
    margin-top: 8px;
    table-layout: fixed; /* Fixed layout for symmetry */
}

.stats-table thead th {
    text-align: center; /* Center align for symmetry */
    padding: 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: transparent;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

.stats-table thead th:first-child {
    text-align: left;
    padding-left: 24px;
}

.stats-table tbody td {
    padding: 16px;
    background: rgba(255, 255, 255, 0.4);
    font-size: 15px; /* Larger font */
    color: var(--text-primary);
    transition: all 0.2s ease;
    text-align: center; /* Center align data */
    white-space: nowrap; /* Prevent wrapping for cleaner look */
    border-bottom: none; /* Remove bottom border in favor of spacing */
}

/* Rounded corners for rows */
.stats-table tbody tr td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    padding-left: 24px;
    text-align: left;
}

.stats-table tbody tr td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.stats-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.01); /* Subtle pop effect */
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.stats-table tbody td:first-child {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Total Row Styling */
.stats-table tbody tr.total-row td {
    background: rgba(255, 255, 255, 0.95);
    font-weight: 800;
    color: var(--text-primary);
    border-top: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.stats-table tbody tr.total-row td:last-child {
    color: var(--success);
}

.stats-table tbody td:last-child {
    font-weight: 700;
    color: var(--text-primary);
}

/* Highlight important values */
.stats-table tbody tr:first-child td:last-child {
    color: var(--success);
    font-size: 16px;
}

@media (max-width: 768px) {
    .stats-table thead th,
    .stats-table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════ */

.referral-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 14px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.referral-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.referral-toast-success {
    border-left: 4px solid var(--success, #22c55e);
}

.referral-toast-success svg {
    color: var(--success, #22c55e);
}

.referral-toast-error {
    border-left: 4px solid var(--danger, #ef4444);
}

.referral-toast-error svg {
    color: var(--danger, #ef4444);
}

.referral-toast span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
}

/* Referral Button Highlight */
.sidebar-referral,
.mobile-referral {
    position: relative;
}

.sidebar-referral::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--success, #22c55e);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.5; transform: translateY(-50%) scale(1.2); }
}

@media (max-width: 768px) {
    .referral-toast {
        bottom: 80px;
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(100px);
    }
    
    .referral-toast.show {
        transform: translateX(0) translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   FLOATING BOOK APPOINTMENT BUTTON
   ═══════════════════════════════════════════════════════════════════ */

.floating-book-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    border: none;
    border-radius: 50px;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: floatPulse 3s ease-in-out infinite;
}

.floating-book-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #d97706 0%, #dc2626 100%);
    color: #ffffff;
}

.floating-book-btn:active {
    transform: translateY(-2px) scale(0.98);
}

.floating-book-btn svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    stroke-width: 2;
    fill: none;
}

@keyframes floatPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1); }
    50% { box-shadow: 0 8px 28px rgba(239, 68, 68, 0.5), 0 4px 12px rgba(0, 0, 0, 0.12); }
}

@media (max-width: 768px) {
    .floating-book-btn {
        bottom: 20px;
        right: 16px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .floating-book-btn {
        bottom: 16px;
        right: 12px;
        padding: 14px;
        border-radius: 50%;
    }
    
    .floating-book-btn span {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   CATALOGUE BUTTON - Sidebar Navigation
   ═══════════════════════════════════════════════════════════════════ */

.sidebar-catalogue,
.mobile-catalogue {
    position: relative;
}

.sidebar-icon.sidebar-catalogue {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.sidebar-icon.sidebar-catalogue:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

.sidebar-icon.sidebar-catalogue svg {
    stroke: #ffffff;
    color: #ffffff;
}

/* Catalogue badge indicator */
.sidebar-catalogue::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    animation: pulse-catalogue 2s infinite;
}

@keyframes pulse-catalogue {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

/* Mobile Catalogue Button */
.mobile-menu-item.mobile-catalogue {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
    border-left: 3px solid #f59e0b;
}

.mobile-menu-item.mobile-catalogue svg {
    color: #f59e0b;
    stroke: #f59e0b;
}

.mobile-menu-item.mobile-catalogue:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.2) 100%);
}

/* Drilldown links and destination highlights */
.record-drilldown {
    appearance: none;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-align: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(199, 137, 37, 0.45);
    text-underline-offset: 3px;
}

.record-drilldown:hover,
.record-drilldown:focus-visible {
    color: #9b6b12;
    outline: none;
    text-decoration-color: currentColor;
}

.record-highlight {
    animation: record-highlight-pulse 1600ms ease-out 1;
    background: rgba(251, 191, 36, 0.18) !important;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.28) !important;
}

@keyframes record-highlight-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.42);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.28);
    }
}
