/* ==========================================================================
   GLOBAL LAYOUT RULES (FROM MEMORY)
   ========================================================================== */
.antigravity-app-root {
    display: flex;
    font-family: 'Inter', sans-serif;
}

.sidebar-main {
    width: 240px;
    background-color: #1e2124;
    color: #abb2bf;
    height: 100vh;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.nav-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 11px;
    color: #5c6370;
}

.sidebar-item:hover {
    background-color: #2c313a;
    color: #ffffff;
}

.data-grid-container {
    flex-grow: 1;
    background-color: #ffffff;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* ==========================================================================
   DESIGN SYSTEM & LOGIN (LIGHT THEME)
   ========================================================================== */
:root {
    /* Colors - Raúl Asencio Palette (Light Theme) */
    --primary: #9b1b1b;
    --primary-hover: #b22222;
    --bg-main: #f0f2f5;
    --bg-sidebar: #1e2124;
    --surface: #ffffff;
    --surface-hover: #f8f9fa;
    --text-main: #1a1a1a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #ffffff;

    /* Layout & Spacing */
    --sidebar-width: 240px;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-size-base: 13px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    color: var(--text-main);
    font-weight: 600;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: 0.2s;
}

a:hover {
    filter: brightness(1.2);
}

.form-group {
    margin-bottom: var(--space-md);
}

label {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 14px;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(155, 27, 27, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    font-size: 14px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-block {
    width: 100%;
}

/* Layout Containers */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-main);
}

.login-card {
    background-color: var(--surface);
    width: 100%;
    max-width: 400px;
    padding: var(--space-xl);
    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);
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo img {
    max-width: 280px;
    height: auto;
}

.login-footer {
    margin-top: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* Utility classes for login form refinement */
.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: -8px;
}

.remember-box {
    display: flex;
    align-items: center;
}

.remember-box input {
    width: auto !important;
    margin-right: 8px;
}

.remember-box label {
    margin-bottom: 0;
    text-transform: none;
    font-size: 13px;
    color: var(--text-muted);
}

.forgot-link {
    font-size: 12px;
}

.login-submit {
    margin-top: var(--space-lg);
}

.version-tag {
    font-size: 10px;
    opacity: 0.5;
}

/* ==========================================================================
   DASHBOARD & NAVIGATION
   ========================================================================== */

/* Main Layout Structure */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 60px 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.topbar {
    grid-column: 2;
    grid-row: 1;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    z-index: 10;
    height: 60px;
}

.view-header-title {
    font-size: 18px;
    margin: 0;
    font-weight: 600;
}

.topbar-right-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.company-badge {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.sidebar-main {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.main-content {
    grid-column: 2;
    grid-row: 2;
    background-color: var(--bg-main);
    overflow-y: auto;
    padding: var(--space-lg);
}

/* Sidebar Components */
.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header img {
    height: 32px;
    filter: brightness(0) invert(1);
    /* Make logo white for dark sidebar */
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-sm) 0;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px var(--space-md);
    color: #abb2bf;
    cursor: pointer;
    transition: 0.2s;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    -webkit-user-select: none;
    user-select: none;
}

.sidebar-item:hover {
    background-color: #2c313a;
    color: #ffffff;
}

.sidebar-item i {
    width: 20px;
    margin-right: 15px;
    text-align: center;
    font-size: 14px;
}

.sidebar-item.active {
    background-color: #2c313a;
    color: #ffffff;
    border-left: 4px solid var(--primary);
}

.sidebar-item .chevron {
    margin-left: auto;
    font-size: 8px;
    transition: transform 0.2s;
    opacity: 0.5;
}

.sidebar-item.open .chevron {
    transform: rotate(90deg);
}

.submenu-item.active {
    color: #ffffff;
    background-color: var(--primary);
    font-weight: 600;
}

/* Sortable Headers */
th.sortable {
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: #e2e8f0 !important;
}

th.sortable i {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.5;
}

/* Sidebar Dropdown Improvements */
.sidebar-submenu {
    background-color: #1a1c1e;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.sidebar-submenu.show {
    max-height: 500px;
}

.dropdown-toggle.expanded .chevron {
    transform: rotate(90deg);
}

/* Dashboard Content */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
}

.stat-card {
    background-color: var(--surface);
    padding: var(--space-lg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-card .label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-main);
}

/* Data Grid / Tables (High Density) */
.data-toolbar {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.action-toolbar {
    display: flex;
    padding: 2px 8px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    gap: 1px;
    align-items: center;
}

.action-btn {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #475569;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
}

.action-btn i {
    font-size: 14px;
}

.action-divider {
    width: 1px;
    height: 16px;
    background: #cbd5e1;
    margin: 0 8px;
}

.filter-toolbar {
    display: flex;
    padding: 6px 12px;
    gap: 15px;
    align-items: center;
}

.search-box {
    flex: 1;
    max-width: 300px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.search-box input {
    border: none;
    padding: 4px 6px;
    font-size: 12px;
}

.search-box input:focus {
    box-shadow: none;
}

.data-table-container {
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.data-table th {
    background: #f8fafc;
    text-align: left;
    padding: 8px 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

.data-table tr:hover {
    background-color: var(--surface-hover);
}

.data-table tr.selected {
    background-color: #f1f5f9;
    border-left: 3px solid var(--primary);
}

.data-table input[type="radio"] {
    cursor: pointer;
}

.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 15px 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 10px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 12px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 12px;
}

.form-grid .full-width {
    grid-column: span 2;
}

.form-grid .span-3 {
    grid-column: span 3;
}

label {
    display: block;
    margin-bottom: 2px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input,
select,
textarea {
    padding: 6px 10px;
    font-size: 13px;
}

textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
}

.text-green {
    color: #22c55e !important;
}

.text-yellow {
    color: #eab308 !important;
}

.text-blue {
    color: #3b82f6 !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.opacity-40 {
    opacity: 0.4 !important;
}

.mt-50 {
    margin-top: 50px !important;
}

.font-13 {
    font-size: 13px !important;
}

.text-red {
    color: #ef4444 !important;
}

.text-bold {
    font-weight: 600 !important;
}

.opacity-disabled {
    opacity: 0.4 !important;
}

.action-divider-line {
    margin: 10px 20px;
    opacity: 0.1;
}

.status-container {
    margin-right: 20px;
}

.full-width-select {
    width: 100%;
}

.btn-close-modal {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
}

.badge-fixed {
    font-weight: 600;
}

.mt-30 {
    margin-top: 30px !important;
}

.mt-10 {
    margin-top: 10px !important;
}

.p-20 {
    padding: 20px !important;
}

.flex-1 {
    flex: 1 !important;
}

.min-w-180 {
    min-width: 180px !important;
}

.w-auto {
    width: auto !important;
}

.w-40 {
    width: 40px !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.text-none {
    text-transform: none !important;
}

.font-12 {
    font-size: 12px !important;
}

.cursor-pointer {
    cursor: pointer !important;
}

.flex-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-white {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.display-none {
    display: none !important;
}