/* ==========================================================================
   SISTEMA CONTABLE WEB V1.0 - CORE DESIGN SYSTEM & LAYOUT
   ========================================================================== */

:root {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-card: #1e293b;
    --border-color: #334155;
    --border-highlight: #475569;
    
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: rgba(2, 132, 199, 0.15);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --info: #38bdf8;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--info);
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-brand .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 16px 12px 8px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.nav-item .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Global Action CTA Button in Sidebar */
.btn-sidebar-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 15px;
    margin: 12px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-sidebar-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    color: white;
}

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

/* Main Header */
.main-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    min-width: 42px;
    min-height: 42px;
    font-size: 20px;
    cursor: pointer;
}

.page-title-header {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.business-badge {
    background: var(--primary-light);
    color: var(--info);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-form { margin: 0; }
.logout-button {
    border: 0;
    background: transparent;
    color: var(--danger);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

/* Content Area */
.content-body {
    padding: 28px;
    flex: 1;
}

/* Responsive Grid System */
.grid {
    display: grid;
    gap: 24px;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-cols-4, .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar { transform: translateX(-100%); box-shadow: 12px 0 30px rgba(0,0,0,.35); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 95; background: rgba(2, 6, 23, .65); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .sidebar.is-open + .sidebar-overlay { opacity: 1; pointer-events: auto; }
    .main-wrapper { margin-left: 0; }
    .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
    .content-body { padding: 16px; }
    .main-header { padding: 0 16px; gap: 10px; }
    .page-title-header { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .header-right { gap: 8px; min-width: 0; }
    .business-badge { max-width: 130px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 6px 10px; }
    .user-name { display: none; }
    .card { padding: 16px; }
    .card-header { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
    .card-header > div:last-child { width: 100%; }
}
