@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #0ea5e9;
    --primary-dark: #0369a1;
    --secondary-color: #38bdf8;
    --bg-dark: #020617;
    /* Deeper dark */
    --bg-sidebar: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    /* Translucent */
    --bg-input: rgba(255, 255, 255, 0.03);
    --text-light: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    min-height: 100vh;
}


/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 24px 32px;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    margin: 4px 16px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    font-weight: 500;
}

.menu-link:hover,
.menu-link.active {
    background: rgba(14, 165, 233, 0.1);
    color: var(--text-light);
}

.menu-link.active {
    background: var(--primary-color);
    color: white;
}

.menu-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

/* Main Layout Area */
.app-layout {
    display: flex;
    flex: 1;
    min-height: 100vh;
}


.main-content {
    flex: 1;
    margin-left: 260px;
    /* Offset for fixed sidebar */
    padding: 32px;
    max-width: 1400px;
}

.container {
    padding: 0;
    max-width: none;
}

a {
    text-decoration: none;
    color: var(--accent);
    transition: var(--transition);
}

a:hover {
    color: var(--secondary-color);
}

/* Header */
header {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    color: var(--text-light);
    font-weight: 700;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

#status {
    font-weight: 600;
    color: var(--accent);
}

/* User Profile Dropdown */
.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-icon {
    font-size: 20px;
    background: var(--primary-color);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-light);
}

.dropdown-arrow {
    font-size: 10px;
    color: var(--text-dim);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    color: var(--text-light);
    font-size: 14px;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 5px 0;
}

/* Dashboard Bento Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto auto;
    gap: 24px;
    margin-top: 24px;
}

.bento-item {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.bento-main {
    grid-column: span 2;
    grid-row: span 1;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2) 0%, rgba(30, 41, 59, 0.7) 100%);
}

.bento-stats {
    grid-column: span 1;
}

.bento-activity {
    grid-column: span 2;
    grid-row: span 2;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-dim);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-light);
}

.stat-diff {
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.diff-up {
    color: var(--success);
}

.diff-down {
    color: var(--danger);
}

/* Activity List */
.activity-list {
    margin-top: 16px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--glass-border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(14, 165, 233, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.activity-info {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.activity-meta {
    font-size: 0.8125rem;
    color: var(--text-dim);
}

.activity-amount {
    font-weight: 700;
    color: var(--text-light);
}

/* Dashboard Menu Grid (Legacy compatibility or updated) */
.dashboard-menu {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 32px;
}

.menu-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100px;
    backdrop-filter: blur(8px);
}

.menu-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    background: rgba(14, 165, 233, 0.05);
}

.menu-card.disabled {
    opacity: 0.4;
    filter: grayscale(1);
    pointer-events: none;
    cursor: default;
    border-left-color: #444 !important;
}

/* Specific Border Colors for Menu Cards (matching existing logic but using vars if possible) */
/* We keep the inline styles or override them with classes if provided, but inline style usually wins unless !important used. 
   Assuming inline styles for border-left color remain in HTML. Ideally, we move to classes. */

/* Section Containers */
.sucursales-section,
.edit-form,
.login-container {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.sucursales-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

/* Buttons */
.btn-new,
.btn-save,
.btn-login {
    background: var(--gradient-main);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-new:hover,
.btn-save:hover,
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0, 86, 179, 0.4);
    filter: brightness(1.1);
}

.btn-edit {
    background-color: rgba(59, 130, 246, 0.2);
    /* Translucent Blue */
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.btn-edit:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-cancel,
.btn-back {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.btn-cancel:hover,
.btn-back:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border-color: var(--text-dim);
}

.btn-delete {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.btn-delete:hover {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* Forms */
.form-group label {
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
}

.form-group input,
.form-group select,
.form-group textarea,
.action-select {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

/* Fix for Select Options in Dark Mode */
select option {
    background-color: var(--bg-card);
    color: var(--text-light);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.action-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent;
    color: var(--text-light);
}

.data-table th {
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--text-light);
    font-weight: 600;
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
}

.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Modals */
.modal-content {
    background-color: var(--bg-card) !important;
    /* Force override inline styles if needed, though usually class wins */
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: var(--shadow-lg);
    border-radius: 12px !important;
}

.close {
    color: var(--text-dim);
}

.close:hover {
    color: var(--text-light);
}

/* Login Page Specifics */
.login-page {
    background-color: var(--bg-dark);
    min-height: 100vh;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 30px;
    margin-bottom: 20px;
}

.login-footer {
    width: 100%;
    max-width: 400px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.login-footer a {
    color: var(--text-dim);
    margin: 0 10px;
    text-decoration: underline;
}

.login-footer a:hover {
    color: var(--accent);
}

.login-footer .copyright {
    display: block;
    margin-top: 10px;
    opacity: 0.7;
}

/* Branch Badge */
.branch-badge {
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.4);
}

/* Scrollbar styling for Webkit */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-card,
.sucursales-section {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Restored Modal Structural Styles */
.modal {
    display: none;
    /* Critical: hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    /* Dimmed background */
    align-items: center;
    justify-content: center;
}

/* Ensure modal content is centered and visible against dark bg */
.modal-content {
    background-color: var(--bg-card);
    /* Dark theme bg */
    margin: auto;
    /* Top margin for basic centering */
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    color: var(--text-light);
    position: relative;
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: var(--text-dim);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: var(--text-light);
    text-decoration: none;
    cursor: pointer;
}

/* Branch Indicator Badge */
.branch-badge {
    background-color: #f39c12;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    vertical-align: middle;
}

.branch-badge i {
    font-size: 16px;
}

/* Mobile Responsiveness Improvements */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 15px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .dashboard-menu {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }

    .menu-card {
        padding: 15px;
    }

    .menu-card h3 {
        font-size: 1.1rem;
    }

    .modal-content {
        width: 95% !important;
        margin: 20% auto;
        padding: 15px;
    }

    /* Stack flex rows in forms */
    .form-group.row,
    .row {
        flex-direction: column !important;
        gap: 15px !important;
    }

    .btn-new,
    .btn-save,
    .btn-back {
        width: 100%;
        text-align: center;
    }

    .data-table th,
    .data-table td {
        padding: 10px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .dashboard-menu {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }
}

/* Hierarchy Privileges */
.priv-child-group {
    margin-left: 25px;
    border-left: 2px solid rgba(255, 255, 255, 0.05);
    padding-left: 10px;
    transition: all 0.3s;
}

.priv-child-group.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}