/**
 * Sistema ERP - Diseño Moderno y Responsivo
 * Mobile-First Approach
 */

/* ==========================================
   IMPORTS
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ==========================================
   CSS VARIABLES - DESIGN SYSTEM
   ========================================== */
:root {
    /* Colors - Corporate Palette (Formal/Ethical) */
    --primary-50: #f0f4f8;
    --primary-100: #d9e2ec;
    --primary-500: #1e3a5f;
    /* Azul corporativo profundo */
    --primary-600: #152d4a;
    /* Hover/active */
    --primary-700: #0e1f33;
    /* Sidebar activo */
    --primary-800: #0f172a;

    /* Colors - Accent (Azul acero, reemplaza rosa) */
    --accent-500: #2563eb;
    --accent-600: #1d4ed8;

    /* Colors - Neutrals */
    --gray-50: #f8f9fb;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Colors - Semantic */
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;
    --info: #2563eb;

    /* Gradients (solo el primario para header) */
    --gradient-primary: linear-gradient(180deg, #152d4a 0%, #0e1f33 100%);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Font Sizes - Mobile First */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-xl: 8px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.10);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;

    /* Z-index */
    --z-modal: 1000;
    --z-dropdown: 900;
    --z-sidebar: 800;
    --z-header: 700;
}

/* Responsive Typography */
@media (min-width: 1024px) {
    :root {
        --text-base: 1.125rem;
        --text-lg: 1.25rem;
        --text-xl: 1.5rem;
        --text-2xl: 1.875rem;
        --text-3xl: 2.25rem;
        --text-4xl: 3rem;
    }
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
}

/* ==========================================
   LOGIN - MODERN DESIGN
   ========================================== */
.login-wrapper {
    position: fixed;
    inset: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

/* Animated Background */
.login-background {
    position: absolute;
    inset: 0;
    background: #1e3a5f;
    z-index: -1;
}

/* Login Container */
.login-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    z-index: 10;
}

/* Brand Section */
.login-brand {
    text-align: center;
    margin-bottom: var(--space-8);
}

.brand-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    background: #ffffff;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    color: var(--primary-500);
}

.brand-icon svg {
    width: 24px;
    height: 24px;
}

.login-brand h1 {
    font-size: calc(var(--text-3xl) * 0.81);
    font-weight: 700;
    color: white;
    margin-bottom: var(--space-2);
    letter-spacing: -0.5px;
}

.brand-subtitle {
    color: #94a3b8;
    font-size: calc(var(--text-sm) * 0.81);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Login Card - Professional */
.login-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

@media (max-width: 480px) {
    .login-card {
        padding: var(--space-6);
    }
}

.card-header {
    text-align: center;
    margin-bottom: var(--space-8);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-header-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    background: var(--primary-500);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.card-header-icon svg {
    width: 24px;
    height: 24px;
}

.card-header h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-2);
}

.card-header p {
    color: var(--gray-500);
    font-size: var(--text-sm);
}

/* Input Groups */
.input-group {
    position: relative;
    margin-bottom: var(--space-6);
}

.input-group input {
    width: 100%;
    padding: var(--space-4) var(--space-4) var(--space-4) var(--space-12);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    transition: all var(--transition-base);
    background: white;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(36, 59, 83, 0.15);
}

.input-group input::placeholder {
    color: transparent;
}

/* Floating Label */
.input-group label {
    position: absolute;
    left: var(--space-12);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-500);
    font-size: var(--text-base);
    pointer-events: none;
    transition: all var(--transition-base);
    background: white;
    padding: 0 var(--space-2);
}

.input-group input:focus+label,
.input-group input:not(:placeholder-shown)+label {
    top: 0;
    font-size: var(--text-sm);
    color: var(--primary-600);
    font-weight: 600;
}

/* Input Icons - SVG */
.input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.input-icon svg {
    width: 20px;
    height: 20px;
}

.input-group:focus-within .input-icon {
    color: var(--primary-600);
}

/* Toggle Password */
.toggle-password {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-1);
    transition: color var(--transition-fast);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

.toggle-password:hover {
    color: var(--primary-600);
}

/* Login Button */
.btn-login {
    width: 100%;
    padding: var(--space-4);
    background: var(--primary-500);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-login svg {
    width: 20px;
    height: 20px;
}

.btn-login:hover {
    background: var(--primary-600);
    box-shadow: var(--shadow-md);
}

.btn-login:active {
    background: var(--primary-700);
}

/* Error Message */
.form-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
    border-left: 4px solid var(--error);
    animation: shake 0.4s;
}

.form-error.hidden {
    display: none;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

/* Login Footer */
.login-footer {
    text-align: center;
    margin-top: var(--space-6);
}

.login-footer a {
    color: var(--primary-600);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.login-footer a svg {
    width: 14px;
    height: 14px;
}

.login-footer a:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* Login Copyright */
.login-copyright {
    text-align: center;
    margin-top: var(--space-6);
}

.login-copyright p {
    color: rgba(255, 255, 255, 0.4);
    font-size: var(--text-xs);
}

/* Loading State */
.btn-login.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

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

/* Icons */
.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.icon-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    color: var(--gray-600);
}

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

/* ==========================================
   RESPONSIVE UTILITIES
   ========================================== */
@media (max-width: 640px) {
    .login-brand h1 {
        font-size: calc(var(--text-2xl) * 0.81);
    }

    .brand-icon {
        width: 44px;
        height: 44px;
        font-size: 2rem;
    }
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

/* ==========================================
   DASHBOARD & APP LAYOUT
   ========================================== */

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--gray-50);
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: white;
    border-bottom: 1px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    z-index: var(--z-header);
    box-shadow: var(--shadow-sm);
}

/* Logo */
.app-logo {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--primary-600);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.app-logo-icon {
    display: none;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--text-2xl);
    cursor: pointer;
    padding: var(--space-2);
    color: var(--gray-700);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-info {
    text-align: right;
    display: none;
}

@media (min-width: 768px) {
    .user-info {
        display: block;
    }
}

.user-name {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--gray-900);
}

.user-role {
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.btn-logout {
    padding: var(--space-2) var(--space-4);
    background: var(--primary-500);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-logout:hover {
    background: var(--primary-600);
}

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 260px;
    height: calc(100vh - 56px);
    background: white;
    border-right: 1px solid var(--gray-300);
    overflow-y: auto;
    transition: transform var(--transition-base);
    z-index: var(--z-sidebar);
}

/* Mobile Sidebar */
@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .app-sidebar.active {
        transform: translateX(0);
    }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: 56px;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-sidebar) - 1);
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* Navigation */
.nav-menu {
    padding: var(--space-4);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    color: var(--gray-700);
    text-decoration: none;
    font-size: var(--text-base);
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: var(--space-1);
    cursor: pointer;
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--primary-600);
}

.nav-item.active {
    background: var(--primary-500);
    color: white;
}

/* Main Content */
.app-main {
    flex: 1;
    margin-top: 56px;
    padding: var(--space-6);
    margin-left: 260px;
    transition: margin-left var(--transition-base);
    min-width: 0;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .app-main {
        margin-left: 0;
        padding: var(--space-4);
    }
}

/* Page Header */
.page-header {
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-2);
}

@media (max-width: 640px) {
    .page-title {
        font-size: var(--text-2xl);
    }
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

@media (max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
}

/* Stat Card */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    border-left: 4px solid var(--primary-500);
    transition: all var(--transition-base);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card-label {
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin-bottom: var(--space-2);
    font-weight: 500;
}

.stat-card-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--gray-900);
}

@media (max-width: 640px) {
    .stat-card-value {
        font-size: var(--text-2xl);
    }
}

/* Card */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

@media (max-width: 640px) {
    .card {
        padding: var(--space-4);
    }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--gray-900);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-500);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-600);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

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

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

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

/* Outline Buttons - Formal Style */
.btn-outline-primary {
    background: transparent;
    color: var(--primary-600);
    border: 1.5px solid var(--primary-600);
    font-weight: 500;
}

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

.btn-outline-secondary {
    background: transparent;
    color: var(--gray-600);
    border: 1.5px solid var(--gray-400);
    font-weight: 500;
}

.btn-outline-secondary:hover {
    background: var(--gray-600);
    color: white;
    border-color: var(--gray-600);
}

.btn-outline-success {
    background: transparent;
    color: var(--success);
    border: 1.5px solid var(--success);
    font-weight: 500;
}

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

.btn-outline-warning {
    background: transparent;
    color: var(--warning);
    border: 1.5px solid var(--warning);
    font-weight: 500;
}

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

.btn-outline-danger {
    background: transparent;
    color: var(--error);
    border: 1.5px solid var(--error);
    font-weight: 500;
}

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

/* Formal Action Buttons */
.action-buttons-formal {
    gap: var(--space-1);
}

.action-buttons-formal .btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    text-transform: capitalize;
    box-shadow: none;
    transition: all 0.2s ease;
}

.action-buttons-formal .btn-sm:hover {
    box-shadow: var(--shadow-sm);
}

.action-buttons-formal .btn-text {
    font-weight: 500;
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.action-buttons {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    min-width: 200px;
}

.action-buttons .btn-sm {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
}

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

.badge-warning {
    background: var(--warning);
    color: white;
}

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

.badge-info {
    background: var(--info);
    color: white;
}

/* Mobile: Full width buttons */
@media (max-width: 640px) {
    .btn {
        width: 100%;
        padding: var(--space-4);
    }
}

/* Mobile Table adjustments */
@media (max-width: 768px) {
    .table-container table {
        min-width: 700px;
    }
    
    .action-buttons .btn-sm {
        padding: var(--space-1);
        font-size: 11px;
    }
    
    .action-buttons-formal .btn-sm {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Additional button styles for compact view */
.action-buttons .btn-sm {
    min-width: auto;
    white-space: nowrap;
}

.action-buttons-formal {
    min-width: auto;
}

/* Ensure table doesn't overflow its container */
#app .table-container {
    max-width: 100%;
    overflow-x: auto;
}

/* Table */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 900px;
}

th {
    padding: var(--space-4);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--gray-200);
    font-size: var(--text-sm);
    white-space: nowrap;
}

/* Table column widths */
table th:nth-child(1), table td:nth-child(1) { width: 120px; }
table th:nth-child(2), table td:nth-child(2) { width: auto; min-width: 150px; }
table th:nth-child(3), table td:nth-child(3) { width: 100px; }
table th:nth-child(4), table td:nth-child(4) { width: 100px; }
table th:nth-child(5), table td:nth-child(5) { width: 110px; }
table th:nth-child(6), table td:nth-child(6) { width: 90px; }
table th:nth-child(7), table td:nth-child(7) { width: auto; min-width: 250px; }

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--gray-50);
}

th {
    padding: var(--space-4);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--gray-200);
    font-size: var(--text-sm);
}

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

/* Mobile Table */
@media (max-width: 768px) {

    th,
    td {
        padding: var(--space-3);
        font-size: var(--text-xs);
    }
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

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

.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    transition: all var(--transition-base);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-4);
    animation: fadeIn 0.2s;
}

/* Quotation Items Grid */
.item-row-grid {
    display: grid;
    grid-template-columns: minmax(200px, 3fr) minmax(70px, 80px) minmax(90px, 110px) minmax(100px, 120px) minmax(80px, 100px) 40px;
    gap: var(--space-3);
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-3);
}

@media (max-width: 640px) {
    .item-row-grid {
        grid-template-columns: 1fr 1fr 40px;
        gap: var(--space-2);
    }

    /* Description spans full width on mobile */
    .item-row-grid>.form-group:first-child {
        grid-column: 1 / -1;
    }
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease-out;
}

@media (max-width: 640px) {
    .modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-2xl);
    cursor: pointer;
    color: var(--gray-400);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .modal-footer {
        flex-direction: column-reverse;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: var(--space-4);
    z-index: calc(var(--z-modal) + 1);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

@media (max-width: 640px) {
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
    }
}

.toast {
    background: white;
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
}

@media (max-width: 640px) {
    .toast {
        min-width: unset;
        width: 100%;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

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

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

/* Responsive Helpers */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }

    .show-mobile {
        display: block;
    }
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: calc(var(--z-modal) + 2);
}

/* Search Results Navigation */
.search-result-item {
    transition: background-color 0.2s;
}

.search-result-item.active {
    background-color: var(--primary-50) !important;
    border-left: 3px solid var(--primary-500);
}

/* Searchable Select Styles */
.search-container {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    position: relative;
    z-index: 10;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-results.show {
    display: block;
}

.search-item {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--gray-100);
}

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

.search-item:hover {
    background-color: var(--primary-50);
    color: var(--primary-700);
}

.search-item.selected {
    background-color: var(--primary-100);
    color: var(--primary-800);
    font-weight: 500;
}

/* Table Row Interactivity */
tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.05);
    /* Light gray for hover */
}

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

/* Client Search Module Styles */
.client-search-wrapper {
    position: relative;
    width: 100%;
}

.client-search-input:disabled {
    background-color: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.7;
}

.client-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.client-search-results.show {
    display: block;
}

.client-search-item {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--gray-100);
}

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

.client-search-item:hover {
    background-color: var(--primary-50);
}

.client-search-item.selected {
    background-color: var(--primary-100);
    border-left: 3px solid var(--primary-500);
}

/* Service Search Module Styles */
.service-search-wrapper {
    position: relative;
    width: 100%;
}

.service-search-input:disabled {
    background-color: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.7;
}

.service-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.service-search-results.show {
    display: block;
}

.service-search-item {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--gray-100);
}

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

.service-search-item:hover {
    background-color: var(--primary-50);
}

.service-search-item.selected {
    background-color: var(--primary-100);
    border-left: 3px solid var(--primary-500);
}