/* ============================================================
   RECIBO FISCAL - Tema Visual Principal
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* === CSS Variables - Light Theme === */
:root, [data-bs-theme="light"] {
    --sidebar-bg: #1a1d2e;
    --sidebar-text: #a8b0c5;
    --sidebar-active: #4f7df9;
    --sidebar-hover-bg: rgba(79, 125, 249, 0.1);
    --sidebar-width: 260px;
    --topbar-bg: #ffffff;
    --topbar-border: #e8eaf0;
    --body-bg: #f3f5f9;
    --card-bg: #ffffff;
    --card-border: #e8eaf0;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --text-primary: #1a1d2e;
    --text-secondary: #6b7280;
    --accent: #4f7df9;
    --accent-light: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* === Dark Theme === */
[data-bs-theme="dark"] {
    --sidebar-bg: #0f1119;
    --sidebar-text: #7b83a0;
    --sidebar-active: #6b8df9;
    --topbar-bg: #181b28;
    --topbar-border: #2a2d3e;
    --body-bg: #12141f;
    --card-bg: #1a1d2e;
    --card-border: #2a2d3e;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --text-primary: #e8eaf0;
    --text-secondary: #8b93a8;
    --accent-light: rgba(79,125,249,0.15);
}

/* === Base === */
* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    font-size: 0.9rem;
    overflow-x: hidden;
}

/* === App Layout === */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header i {
    font-size: 1.5rem;
    color: var(--sidebar-active);
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    color: #fff;
    background: var(--sidebar-hover-bg);
}

.sidebar-nav li a.active {
    color: #fff;
    background: var(--sidebar-hover-bg);
    border-left-color: var(--sidebar-active);
    font-weight: 500;
}

.sidebar-nav li a i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,0.06);
    margin: 0.5rem 1.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--sidebar-text);
    font-size: 0.8rem;
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.expanded {
    margin-left: 0;
}

/* === Top Navbar === */
.top-navbar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.sidebar-toggle {
    color: var(--text-secondary);
    padding: 0.25rem;
}

.theme-toggle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.user-dropdown {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
}

/* === Page Content === */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* === Cards === */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* === Stat Cards === */
.stat-card {
    padding: 1.25rem;
    border-radius: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

/* === Tables === */
.table {
    font-size: 0.85rem;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
}

/* === Badges === */
.badge-emitido {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    font-weight: 500;
    padding: 0.35em 0.75em;
    border-radius: 0.375rem;
}

.badge-cancelado {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    font-weight: 500;
    padding: 0.35em 0.75em;
    border-radius: 0.375rem;
}

/* === Buttons === */
.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 500;
}

.btn-accent:hover {
    background: #3d6ae0;
    color: #fff;
}

/* === Forms === */
.form-label {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    font-size: 0.875rem;
    border-color: var(--card-border);
    border-radius: 0.5rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.15);
}

/* === Footer === */
.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--card-border);
}

/* === Page Title === */
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* === Custom Select2 === */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--card-border) !important;
    border-radius: 0.5rem !important;
    font-size: 0.875rem !important;
}

/* === Recibo Document === */
.recibo-document {
    background: #fff;
    color: #1a1d2e;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    border: 1px solid #ddd;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.recibo-document .recibo-header {
    text-align: center;
    border-bottom: 3px solid #1a1d2e;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.recibo-document .recibo-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #1a1d2e;
    margin: 0.5rem 0;
}

.recibo-document .recibo-section {
    border: 1px solid #ccc;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
    overflow: hidden;
}

.recibo-document .recibo-section-title {
    background: #e8eaf0;
    color: #1a1d2e;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #ccc;
}

.recibo-document .recibo-section-body {
    padding: 0.75rem;
    font-size: 0.82rem;
}

.recibo-document .recibo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.recibo-document .recibo-table th,
.recibo-document .recibo-table td {
    border: 1px solid #ccc;
    padding: 0.4rem 0.6rem;
}

.recibo-document .recibo-table th {
    background: #e8eaf0;
    font-weight: 600;
    text-align: center;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.recibo-document .recibo-total {
    text-align: right;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #ccc;
}

.recibo-document .recibo-obs {
    font-size: 0.8rem;
    color: #555;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
}

.recibo-document .recibo-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid #1a1d2e;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.8rem;
}

/* === Item row in emission form === */
.item-row {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.item-row:hover {
    border-color: var(--accent);
}

/* === Responsive === */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

/* === Print === */
@media print {
    .sidebar, .top-navbar, .app-footer, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .recibo-document { box-shadow: none; border: none; padding: 0; max-width: 100%; }
    body { background: #fff; }
}

/* === Loading spinner === */
.spinner-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-overlay.active {
    display: flex;
}

/* === Login page === */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d2e 0%, #2d3561 50%, #4f7df9 100%);
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .login-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-card .login-subtitle {
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

/* === Pagination === */
.pagination .page-link {
    font-size: 0.82rem;
    border-radius: 0.375rem;
    margin: 0 0.1rem;
}
