/* =========================================
   Modern SaaS / Glassmorphism Design System 
   ========================================= */

:root {
    /* Color Palette - Dark Mode Default for that sleek "Hacker/Tech" feel */
    --bg-main: #0f172a; /* Slate 900 */
    --bg-sidebar: #1e293b; /* Slate 800 */
    --bg-panel: rgba(30, 41, 59, 0.7); /* Glass slate */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;

    /* Status Colors */
    --status-recibido: #64748b; /* Slate */
    --status-revision: #eab308; /* Yellow */
    --status-repuesto: #f97316; /* Orange */
    --status-reparado: #10b981; /* Emerald */
    --status-entregado: #22c55e; /* Green */

    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);
    
    --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Animations Core */
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

/* Light Mode Variables override */
body.light-mode {
    --bg-main: #f0fdf4; /* Very light slate/greenish */
    /* --bg-main: #f8fafc; */
    --bg-sidebar: #ffffff;
    --bg-panel: rgba(255, 255, 255, 0.85);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    
    --border-color: rgba(0, 0, 0, 0.1);
    --border-light: rgba(0, 0, 0, 0.05);
    
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, .count {
    font-family: 'Outfit', sans-serif;
}

/* Layout Core */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* =========================================
   Sidebar
   ========================================= */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
    transition: background-color var(--transition-normal), border var(--transition-normal);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.logo img {
    animation: floatLogo 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

@keyframes floatLogo {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-4px) scale(1.02); }
    100% { transform: translateY(0px); }
}

.logo-icon {
    font-size: 32px;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.nav-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    transition: left 0.7s ease;
}

.nav-item:hover::before {
    left: 100%;
}

.nav-item i {
    font-size: 20px;
    transition: transform var(--transition-fast);
}

.nav-item:hover {
    background: var(--border-light);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item:hover i {
    transform: scale(1.1);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    box-shadow: var(--shadow-glow);
    animation: pulseGlow 3s infinite;
}

/* =========================================
   Main Content Area
   ========================================= */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    position: relative;
    /* subtle gradient background pattern */
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.05), transparent 400px), 
                radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.05), transparent 400px);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: rgba(var(--bg-main), 0.5); /* Needs proper handling but transparent is fine */
}

h1#pageTitle {
    font-size: 28px;
    margin-bottom: 4px;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--border-light);
    transform: translateY(-2px);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    color: white;
}

/* =========================================
   Views core
   ========================================= */
.view-container {
    padding: 0 40px 40px;
    flex-grow: 1;
}

.view {
    display: none;
    animation: fadeInView 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view.active {
    display: block;
}

/* Glass panel utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

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

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease, border-color 0.4s ease;
    animation: zoomIn 0.5s ease-out backwards;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    border-color: rgba(255,255,255,0.2);
}

.stat-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card:hover .stat-icon {
    transform: rotate(15deg) scale(1.15);
}

.stat-icon.total { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.stat-icon.working { background: rgba(234, 179, 8, 0.1); color: var(--status-revision); }
.stat-icon.ready { background: rgba(16, 185, 129, 0.1); color: var(--status-reparado); }

.stat-info h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.stat-info p {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

/* =========================================
   Kanban Board
   ========================================= */
.kanban-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    min-height: 500px;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    width: 300px;
    box-shadow: var(--shadow-soft);
}

.search-box i {
    color: var(--text-secondary);
    font-size: 18px;
    margin-right: 8px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
}

.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    height: 100%;
}

.k-column {
    flex: 1;
    min-width: 260px;
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

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

.k-column-header .count {
    background: var(--bg-main);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Header colors */
.col-recibido span:first-child { color: var(--status-recibido); }
.col-revision span:first-child { color: var(--status-revision); }
.col-repuesto span:first-child { color: var(--status-repuesto); }
.col-reparado span:first-child { color: var(--status-reparado); }
.col-entregado span:first-child { color: var(--status-entregado); }

.k-cards {
    padding: 12px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Card */
.ticket-card {
    background: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    position: relative;
    overflow: hidden;
}

.ticket-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.ticket-card[data-status="Recibido"]::before { background-color: var(--status-recibido); }
.ticket-card[data-status="Revisión"]::before { background-color: var(--status-revision); }
.ticket-card[data-status="Repuesto"]::before { background-color: var(--status-repuesto); }
.ticket-card[data-status="Reparado"]::before { background-color: var(--status-reparado); }
.ticket-card[data-status="Entregado"]::before { background-color: var(--status-entregado); }

.ticket-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 12px 24px -6px rgba(0,0,0,0.2);
    border-color: var(--accent-blue);
    z-index: 2;
}

.tc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.tc-id {
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.tc-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.tc-client {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.tc-device {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tc-device i {
    font-size: 14px;
}

/* =========================================
   Intake Form View
   ========================================= */
.form-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px;
}

.form-header {
    margin-bottom: 32px;
}

.form-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.form-header p {
    color: var(--text-secondary);
}

.form-section {
    margin-bottom: 32px;
}

.form-section h3 {
    font-size: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-blue);
}

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

.form-grid.single-col {
    grid-template-columns: 1fr;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.required {
    color: #ef4444;
}

.input-group input,
.input-group textarea,
.input-group select {
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color var(--transition-fast);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    width: 100%;
    appearance: none;
    cursor: pointer;
}

.select-wrapper i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.divider {
    height: 1px;
    background: var(--border-light);
    margin: 32px 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 40px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(59, 130, 246, 0.5);
}

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

.btn-outline:hover {
    background: var(--border-light);
}

/* =========================================
   Modal specific
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

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

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.close-modal:hover {
    color: var(--text-primary);
}

.ticket-details h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.id-badge {
    background: var(--bg-main);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--accent-blue);
    font-size: 14px;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 24px 0;
}

.detail-item label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.detail-item p {
    font-size: 15px;
    font-weight: 500;
}

.status-update {
    background: var(--bg-main);
    padding: 16px;
    border-radius: var(--radius-md);
    margin: 24px 0;
    border: 1px solid var(--border-light);
}

.status-update label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.status-select {
    width: 100%;
    padding: 12px;
    background: var(--bg-sidebar);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    outline: none;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* =========================================
   Toast Container (Notifications)
   ========================================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    opacity: 0;
    transition: all var(--transition-normal);
}

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

.toast i {
    font-size: 24px;
    color: var(--status-reparado);
}

/* =========================================
   Print Area (Ticket)
   ========================================= */
.print-only {
    display: none;
}

@media print {
    @page {
        margin: 0;
        size: letter;
    }

    body * {
        visibility: hidden;
    }
    
    .print-only, .print-only * {
        visibility: visible;
    }
    
    .print-only {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100vh;
        overflow: hidden;
        padding: 15mm;
        box-sizing: border-box;
        color: #000;
        background: #fff;
        font-family: 'Inter', sans-serif;
    }

    #printArea {
        width: 100%;
        height: 100%;
        max-width: 215.9mm;
        margin: 0 auto;
        font-size: 13px;
        line-height: 1.4;
    }
    
    .print-header-letter {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 2px solid #1e293b;
        padding-bottom: 20px;
        margin-bottom: 30px;
    }

    .print-logo-container img {
        max-height: 80px;
        width: auto;
    }

    .print-company-info {
        flex: 1;
        margin-left: 20px;
    }

    .print-ticket-info {
        text-align: right;
    }

    .print-section-title {
        background-color: #f1f5f9;
        color: #1e293b;
        font-weight: bold;
        padding: 8px 12px;
        margin: 20px 0 10px 0;
        border-left: 4px solid #3b82f6;
        font-size: 16px;
    }

    .print-grid-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-bottom: 20px;
        font-size: 15px;
    }

    .print-box {
        border: 1px solid #cbd5e1;
        padding: 15px;
        border-radius: 8px;
        background-color: #fafafa;
        min-height: 60px;
        font-size: 15px;
    }

    .print-financials {
        margin-top: 30px;
        width: 50%;
        float: right;
    }

    .print-terms {
        clear: both;
        margin-top: 50px;
        font-size: 11px;
        color: #64748b;
        text-align: justify;
        line-height: 1.4;
    }

    .print-signatures {
        display: flex;
        justify-content: space-around;
        margin-top: 60px;
    }

    .sig-box {
        text-align: center;
        width: 250px;
    }

    .sig-line {
        border-bottom: 1px solid #000;
        height: 40px;
        margin-bottom: 10px;
    }

    .barcode {
        text-align: left;
        margin-top: 20px;
        font-family: 'Code39', monospace;
        font-size: 32px;
    }

    .print-stamp {
        position: absolute;
        top: 150px;
        right: 40px;
        border: 4px solid;
        border-radius: 8px;
        padding: 8px 16px;
        font-size: 22px;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 2px;
        opacity: 0.4;
        transform: rotate(-15deg);
        font-family: 'Courier New', Courier, monospace;
        z-index: 10;
        pointer-events: none;
    }

    .stamp-recibido { color: #64748b; border-color: #64748b; }
    .stamp-revision { color: #eab308; border-color: #eab308; }
    .stamp-repuesto { color: #f97316; border-color: #f97316; }
    .stamp-reparado { color: #10b981; border-color: #10b981; }
    .stamp-entregado { color: #22c55e; border-color: #22c55e; }
}
