@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

:root {
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Primary Colors (Oficina / General) */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;
    --color-primary-subtle: #dbeafe;
    
    /* Admin Colors */
    --color-purple: #7c3aed;
    --color-purple-hover: #6d28d9;
    --color-purple-subtle: #ede9fe;
    
    /* Buyer Colors */
    --color-warning: #f59e0b;
    --color-warning-hover: #d97706;
    --color-warning-subtle: #fef3c7;
    
    /* Success Colors */
    --color-success: #10b981;
    --color-success-hover: #059669;
    --color-success-subtle: #d1fae5;
    
    /* Neutral & Backgrounds */
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(37, 99, 235, 0.15);
    --sidebar-active-border: #3b82f6;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: var(--font-family-base);
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* App Layout Structure */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-app);
}

.sidebar-container {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo-wrapper {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    color: #60a5fa;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 14px;
    overflow-y: auto;
}

.menu-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #475569;
    padding: 8px 12px 6px;
    letter-spacing: 0.5px;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.2s ease;
    margin-bottom: 3px;
}

.nav-item-link i {
    font-size: 17px;
}

.nav-item-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06);
}

.nav-item-link.active {
    color: #60a5fa;
    background-color: var(--sidebar-active-bg);
    border-left: 3px solid var(--sidebar-active-border);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-card-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #3b82f6;
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name {
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
}

.user-role-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    margin-top: 2px;
}

.badge-admin { background: #581c87; color: #c084fc; }
.badge-comprador { background: #78350f; color: #fcd34d; }
.badge-oficina { background: #1e3a8a; color: #93c5fd; }

/* Main Content & Top Navbar */
.main-content-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-navbar {
    height: 65px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.tenant-badge {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 13px;
    border: 1px solid var(--color-primary-subtle);
}

.buyer-badge {
    background-color: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}

.admin-badge {
    background-color: #faf5ff;
    color: #7e22ce;
    border-color: #e9d5ff;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-user-dropdown {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 4px 12px 4px 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-user-dropdown:hover,
.btn-user-dropdown:focus {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.user-dropdown-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999;
    background: transparent;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    min-width: 230px;
    max-width: 280px;
    z-index: 1000;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -6px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.user-dropdown-menu .dropdown-header {
    padding: 6px 10px 8px 10px;
}

.user-dropdown-menu .dropdown-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.15s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
}

.user-dropdown-menu .dropdown-item:hover {
    background-color: #f1f5f9;
    color: var(--color-primary);
}

.user-dropdown-menu .dropdown-item.text-danger:hover {
    background-color: #fef2f2;
    color: #dc2626 !important;
}

.user-dropdown-menu .dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
    opacity: 0.8;
}

.page-container {
    padding: 28px 32px;
    flex: 1;
}

/* Stat Cards */
.stat-card {
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06) !important;
}

.clickable-card {
    cursor: pointer;
    user-select: none;
    position: relative;
    border: 2px solid transparent !important;
}

.clickable-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08) !important;
}

.clickable-card:active {
    transform: translateY(-1px);
}

.clickable-card.active-filter-card-danger {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2), 0 8px 20px rgba(239, 68, 68, 0.1) !important;
}

.clickable-card.active-filter-card-warning {
    border-color: #f59e0b !important;
    background-color: #fffbeb !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), 0 8px 20px rgba(245, 158, 11, 0.1) !important;
}

.clickable-card.active-filter-card-primary {
    border-color: #3b82f6 !important;
    background-color: #eff6ff !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 8px 20px rgba(59, 130, 246, 0.1) !important;
}

.clickable-card.active-filter-card-success {
    border-color: #10b981 !important;
    background-color: #ecfdf5 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2), 0 8px 20px rgba(16, 185, 129, 0.1) !important;
}

.clickable-card.active-filter-card-info {
    border-color: #06b6d4 !important;
    background-color: #ecfeff !important;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2), 0 8px 20px rgba(6, 182, 212, 0.1) !important;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

/* Auth Layout */
.auth-layout-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    border-radius: 16px;
    background: #ffffff;
}

.login-brand-icon {
    width: 64px;
    height: 64px;
    background: #eff6ff;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Custom Status Badges */
.badge-draft { background-color: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-pending { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-in-progress { background-color: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-partial { background-color: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.badge-finished { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-cancelled { background-color: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.plate-badge {
    font-family: monospace;
    font-weight: 700;
    background: #1e293b;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    letter-spacing: 1px;
}

/* Buttons and Custom Colors */
.btn-purple {
    background-color: var(--color-purple);
    color: #ffffff;
    border-color: var(--color-purple);
}

.btn-purple:hover {
    background-color: var(--color-purple-hover);
    color: #ffffff;
}

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

.btn-outline-purple:hover {
    background-color: var(--color-purple);
    color: #ffffff;
}

.text-purple {
    color: var(--color-purple) !important;
}

.bg-purple {
    background-color: var(--color-purple) !important;
}

.bg-purple-subtle {
    background-color: var(--color-purple-subtle) !important;
}

/* Currency Input Styling */
.currency-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-prefix {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    pointer-events: none;
}

.currency-input {
    padding-left: 32px !important;
    font-family: monospace;
    font-weight: 600;
    text-align: right;
}

/* Custom Modals */
.modal-backdrop-custom {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 16px;
}

.modal-dialog-custom {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-dialog-custom.modal-md { max-width: 520px; }
.modal-dialog-custom.modal-lg { max-width: 760px; }

.modal-header-custom {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title-custom {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.btn-close-custom {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body-custom {
    padding: 20px;
    overflow-y: auto;
}

/* Micro-animations */
.spin-slow {
    animation: spin 3s linear infinite;
}

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

/* Modern Clean Segmented Controls & Pill Groups */
.segmented-control {
    display: inline-flex;
    align-items: center;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
    width: 100%;
}

.segmented-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-align: center;
}

.segmented-btn:hover:not(:disabled) {
    color: #0f172a;
    background-color: rgba(255, 255, 255, 0.6);
}

.segmented-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.segmented-btn.active {
    background-color: #ffffff;
    color: #0f172a;
    font-weight: 600;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.segmented-btn.active-primary {
    background-color: #ffffff;
    color: #2563eb;
    font-weight: 600;
    border-color: rgba(37, 99, 235, 0.2);
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}

.segmented-btn.active-success {
    background-color: #ffffff;
    color: #059669;
    font-weight: 600;
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.12);
}

.segmented-btn.active-amber {
    background-color: #ffffff;
    color: #d97706;
    font-weight: 600;
    border-color: rgba(217, 119, 6, 0.2);
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.12);
}

.segmented-btn.active-neutral {
    background-color: #ffffff;
    color: #334155;
    font-weight: 600;
    border-color: rgba(51, 65, 85, 0.2);
    box-shadow: 0 1px 3px rgba(51, 65, 85, 0.12);
}

/* Subtle Offer Card Clean Style */
.clean-offer-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.clean-offer-card:hover {
    border-color: #cbd5e1;
}

.clean-offer-card.is-recommended {
    border-color: #10b981;
    background-color: #fcfdfc;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
}

.only-print {
    display: none;
}

/* PRINT MEDIA QUERY FOR CLEAN A4 FORMAT */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .sidebar-container, .top-navbar, .no-print, .btn, .dropdown, .nav-pills, .alert-dismissible {
        display: none !important;
    }

    .main-content-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .page-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    body {
        background: #ffffff !important;
        font-size: 11pt;
        color: #000000 !important;
    }

    .only-print {
        display: block !important;
    }

    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
        background: #ffffff !important;
    }

    .print-document-container {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .supplier-print-block {
        page-break-inside: avoid;
        margin-bottom: 25px !important;
    }

    .table {
        border-color: #dee2e6 !important;
    }

    .table-light {
        background-color: #f8f9fa !important;
    }

    .badge {
        border: 1px solid #ccc !important;
    }
}