/* ==========================================
   WEFT AI - Fluent Design System
   Common Stylesheet for Consistent UI
   ========================================== */

/* ==========================================
   1. CSS VARIABLES
   ========================================== */
:root {
    /* PRIMARY COLORS - Purple (weft.one brand) */
    --color-primary: #a855f7;
    --color-primary-hover: #9333ea;
    --color-primary-foreground: #ffffff;
    
    /* SECONDARY COLORS */
    --color-secondary: #3b82f6;
    --color-secondary-hover: #2563eb;
    
    /* BACKGROUNDS */
    --color-bg: #fafafa;
    --color-card: #f5f5f7;
    --color-card-border: #e8e8eb;
    
    /* TEXT COLORS */
    --color-text: #171719;
    --color-text-secondary: #585863;
    
    /* BORDERS */
    --color-border: #dfe0e8;
    --color-input: #b8b8c5;
    
    /* STATUS COLORS */
    --color-error: #d73a49;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    
    /* GRADIENTS */
    --gradient-primary: linear-gradient(to right, #9333ea, #3b82f6);
    --gradient-primary-hover: linear-gradient(to right, #7e22ce, #2563eb);
    
    /* FLUENT SPACING */
    --fluent-spacing-4: 4px;
    --fluent-spacing-8: 8px;
    --fluent-spacing-12: 12px;
    --fluent-spacing-16: 16px;
    --fluent-spacing-24: 24px;
    --fluent-spacing-32: 32px;
    --fluent-spacing-48: 48px;
    
    /* SHADOWS - weft.one elevation system */
    --shadow-sm: 0px 2px 0px 0px rgba(23, 23, 25, 0.05), 0px 1px 2px -1px rgba(23, 23, 25, 0.08);
    --shadow-md: 0px 2px 0px 0px rgba(23, 23, 25, 0.07), 0px 2px 4px -1px rgba(23, 23, 25, 0.12);
    --shadow-lg: 0px 2px 0px 0px rgba(23, 23, 25, 0.08), 0px 4px 6px -1px rgba(23, 23, 25, 0.15);
    --shadow-xl: 0px 2px 0px 0px rgba(23, 23, 25, 0.09), 0px 8px 10px -1px rgba(23, 23, 25, 0.18);
    
    /* BORDER RADIUS - weft.one standards */
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 9px;
    --radius-xl: 12px;
    --radius-full: 9999px;
    
    /* Legacy shadow compatibility */
    --fluent-shadow-2: var(--shadow-sm);
    --fluent-shadow-4: var(--shadow-md);
    --fluent-shadow-8: var(--shadow-lg);
    --fluent-shadow-16: var(--shadow-xl);
    --fluent-shadow-64: var(--shadow-xl);
    
    /* Legacy radius compatibility */
    --fluent-radius-4: var(--radius-sm);
    --fluent-radius-8: var(--radius-md);
    --fluent-radius-12: var(--radius-xl);
    
    /* Legacy color compatibility */
    --color-surface: var(--color-card);
    --color-accent: var(--color-success);
    --color-charcoal: #1E1F25;
}

/* ==========================================
   2. BASE STYLES & RESET
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ==========================================
   3. HEADER & NAVIGATION
   ========================================== */
.header {
    background: var(--color-primary);
    color: white;
    padding: var(--fluent-spacing-16) var(--fluent-spacing-24);
    box-shadow: var(--fluent-shadow-4);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--fluent-spacing-4);
    color: white;
}

.header p {
    opacity: 0.9;
    font-size: 0.875rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.logo-icon {
    display: inline-block;
    margin-right: var(--fluent-spacing-8);
}

.hamburger,
.hamburger-menu {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.75rem;
    cursor: pointer;
    padding: var(--fluent-spacing-8);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--fluent-radius-8);
    transition: background 0.2s ease;
}

.hamburger:hover,
.hamburger-menu:hover {
    background: rgba(255,255,255,0.15);
}

.nav-links {
    display: flex;
    gap: var(--fluent-spacing-12);
    align-items: center;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: var(--fluent-spacing-12) var(--fluent-spacing-16);
    border-radius: var(--fluent-radius-8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9375rem;
    font-weight: 500;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.15);
}

.logout-btn {
    background: var(--color-error);
    color: white;
    border: none;
    padding: var(--fluent-spacing-12) var(--fluent-spacing-16);
    border-radius: var(--fluent-radius-8);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--fluent-shadow-2);
    min-height: 44px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
}

.logout-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--fluent-shadow-8);
}

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

/* ==========================================
   4. CONTAINER & LAYOUT
   ========================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--fluent-spacing-24);
}

.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 98;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ==========================================
   5. BUTTONS
   ========================================== */
.btn {
    padding: var(--fluent-spacing-12) var(--fluent-spacing-24);
    border: none;
    border-radius: var(--fluent-radius-8);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', sans-serif;
    min-height: 44px;
    box-shadow: var(--fluent-shadow-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--fluent-spacing-8);
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: var(--fluent-shadow-4);
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #d9d6d3;
    box-shadow: var(--fluent-shadow-4);
    transform: translateY(-1px);
}

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

.btn-secondary:disabled {
    background: #f0f0f0;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

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

.btn-success:hover {
    background: #24c99a;
    box-shadow: var(--fluent-shadow-4);
    transform: translateY(-1px);
}

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

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

.btn-danger:hover {
    background: #c25a4c;
    box-shadow: var(--fluent-shadow-4);
    transform: translateY(-1px);
}

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

.btn-ghost {
    background: transparent;
    color: var(--color-text);
    box-shadow: none;
    border: 1px solid var(--color-border);
}

.btn-ghost:hover {
    background: var(--color-card);
    border-color: var(--color-primary);
    box-shadow: var(--fluent-shadow-2);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: var(--fluent-radius-4);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 32px;
}

.btn-small.btn-edit {
    background: #667eea;
    color: white;
}

.btn-small.btn-edit:hover {
    background: #5568d3;
}

.btn-small.btn-edit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* CTA Button (for landing pages) */
.cta-button {
    display: inline-flex;
    align-items: center;
    gap: var(--fluent-spacing-12);
    background: var(--gradient-primary);
    color: white;
    padding: var(--fluent-spacing-16) var(--fluent-spacing-32);
    border-radius: var(--fluent-radius-8);
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: var(--fluent-shadow-8);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 56px;
    justify-content: center;
}

.cta-button:hover {
    background: var(--gradient-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--fluent-shadow-16);
}

/* ==========================================
   6. CARDS
   ========================================== */
.stat-card {
    background: white;
    padding: var(--fluent-spacing-24);
    border-radius: var(--fluent-radius-12);
    box-shadow: var(--fluent-shadow-4);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--fluent-shadow-8);
}

.stat-card h3 {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--fluent-spacing-8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.card {
    background: white;
    border-radius: var(--fluent-radius-12);
    box-shadow: var(--fluent-shadow-4);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--fluent-shadow-8);
}

/* ==========================================
   7. FORMS
   ========================================== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: var(--fluent-spacing-12);
    border: 1px solid var(--color-border);
    border-radius: var(--fluent-radius-8);
    font-size: 0.9375rem;
    font-family: 'Inter', sans-serif;
    min-height: 44px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    color: var(--color-text);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.form-group {
    margin-bottom: var(--fluent-spacing-16);
}

.form-label {
    display: block;
    margin-bottom: var(--fluent-spacing-8);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text);
}

.form-helper {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-top: var(--fluent-spacing-4);
}

/* Checkbox and Radio Styles */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    min-height: 20px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: var(--fluent-spacing-8);
    cursor: pointer;
    user-select: none;
}

/* ==========================================
   8. MODALS
   ========================================== */
.modal {
    position: fixed;
    inset: 0;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    place-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: var(--fluent-spacing-16);
    z-index: 1001;
    display: none;
}

.modal.show {
    display: grid;
}

.modal > * {
    background: white;
    padding: var(--fluent-spacing-32);
    border-radius: var(--fluent-radius-12);
    box-shadow: var(--fluent-shadow-64);
    min-width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.show {
    display: block;
}

.modal h3 {
    margin-bottom: var(--fluent-spacing-16);
    font-size: 1.5rem;
    color: var(--color-text);
}

.modal-buttons {
    display: flex;
    gap: var(--fluent-spacing-12);
    justify-content: flex-end;
    margin-top: var(--fluent-spacing-24);
}

.modal-overlay,
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 999;
}

.modal-overlay.show,
.overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* ==========================================
   9. BADGES & CHIPS
   ========================================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--fluent-radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
}

/* Status badges */
.badge.status-proposed { background: #e3f2fd; color: #1976d2; }
.badge.status-awaiting_approval { background: #fff3e0; color: #f57c00; }
.badge.status-approved { background: #e8f5e9; color: #388e3c; }
.badge.status-executing { background: #f3e5f5; color: #7b1fa2; }
.badge.status-completed { background: #c8e6c9; color: #2e7d32; }
.badge.status-completed::before { content: '✓ '; }
.badge.status-failed { background: #ffebee; color: #c62828; }
.badge.status-failed::before { content: '✕ '; }
.badge.status-dismissed { background: #f5f5f5; color: #757575; }
.badge.status-canceled { background: #fff3e0; color: #e65100; }
.badge.status-snoozed { background: #e1f5fe; color: #0277bd; }

/* Intent badges */
.badge.intent-reply_email { background: #e8eaf6; color: #3f51b5; }
.badge.intent-send_teams_message { background: #fce4ec; color: #c2185b; }
.badge.intent-create_task { background: #fff9c4; color: #f57f17; }
.badge.intent-flag_followup { background: #e0f2f1; color: #00695c; }

/* Priority badges */
.badge.priority-high { background: #ffebee; color: #c62828; }
.badge.priority-normal { background: #f5f5f5; color: #616161; }
.badge.priority-low { background: #e8f5e9; color: #388e3c; }

/* ==========================================
   10. EMPTY STATES
   ========================================== */
.empty-state {
    text-align: center;
    padding: var(--fluent-spacing-48) var(--fluent-spacing-24);
    color: var(--color-text-secondary);
}

.empty-state svg,
.empty-state .icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--fluent-spacing-16);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: var(--fluent-spacing-8);
    color: var(--color-text);
}

.empty-state p {
    font-size: 1rem;
    color: var(--color-text-secondary);
}

/* ==========================================
   11. TABLES
   ========================================== */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th {
    text-align: left;
    padding: var(--fluent-spacing-12) var(--fluent-spacing-16);
    background: var(--color-card);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
}

td {
    padding: var(--fluent-spacing-12) var(--fluent-spacing-16);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9375rem;
}

tr:hover {
    background: var(--color-bg);
}

tr:last-child td {
    border-bottom: none;
}

/* ==========================================
   12. UTILITIES
   ========================================== */

/* Loading States */
.loading {
    text-align: center;
    padding: var(--fluent-spacing-32);
    color: var(--color-text-secondary);
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-card);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error States */
.error {
    background: #ffebee;
    color: #c62828;
    padding: var(--fluent-spacing-16);
    border-radius: var(--fluent-radius-8);
    margin-bottom: var(--fluent-spacing-16);
    border: 1px solid #ffcdd2;
}

/* Success States */
.success {
    background: #e8f5e9;
    color: #2e7d32;
    padding: var(--fluent-spacing-16);
    border-radius: var(--fluent-radius-8);
    margin-bottom: var(--fluent-spacing-16);
    border: 1px solid #c8e6c9;
}

/* Warning States */
.warning {
    background: #fff3e0;
    color: #e65100;
    padding: var(--fluent-spacing-16);
    border-radius: var(--fluent-radius-8);
    margin-bottom: var(--fluent-spacing-16);
    border: 1px solid #ffe0b2;
}

/* Info States */
.info {
    background: #e3f2fd;
    color: #1976d2;
    padding: var(--fluent-spacing-16);
    border-radius: var(--fluent-radius-8);
    margin-bottom: var(--fluent-spacing-16);
    border: 1px solid #bbdefb;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--fluent-spacing-24) 0;
}

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }

/* Spacing Utilities */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--fluent-spacing-8); }
.mt-2 { margin-top: var(--fluent-spacing-16); }
.mt-3 { margin-top: var(--fluent-spacing-24); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--fluent-spacing-8); }
.mb-2 { margin-bottom: var(--fluent-spacing-16); }
.mb-3 { margin-bottom: var(--fluent-spacing-24); }

/* ==========================================
   13. RESPONSIVE DESIGN
   ========================================== */

/* Tablet */
@media (max-width: 1023px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .header p {
        font-size: 0.8125rem;
    }

    .container {
        padding: var(--fluent-spacing-16);
    }
}

/* Mobile */
@media (max-width: 767px) {
    .hamburger,
    .hamburger-menu {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 70px;
        right: -100%;
        width: 280px;
        height: calc(100vh - 70px);
        background: var(--color-primary);
        flex-direction: column;
        align-items: stretch;
        padding: var(--fluent-spacing-16);
        box-shadow: var(--fluent-shadow-16);
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 99;
        overflow-y: auto;
    }

    .nav-links.mobile-open {
        right: 0;
    }

    .nav-links a,
    .logout-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
        margin: 0;
    }

    .container {
        padding: var(--fluent-spacing-16);
    }

    .modal {
        min-width: 300px;
        padding: var(--fluent-spacing-24);
    }

    .btn {
        width: 100%;
    }
}

/* Print */
@media print {
    .header,
    .nav-links,
    .hamburger,
    .hamburger-menu,
    .logout-btn {
        display: none;
    }

    body {
        background: white;
    }

    .card,
    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
