:root {
    --primary-color: #00AB55; /* Verde MUI característico o similar */
    --primary-dark: #007B55;
    --primary-light: #C8FACD;
    --secondary-color: #3366FF;
    --text-primary: #212B36;
    --text-secondary: #637381;
    --bg-body: #F9FAFB;
    --bg-paper: #FFFFFF;
    --divider: #E0E0E0; /* F2F4F7 más suave */
    --sidebar-width: 280px;
    --header-height: 64px;
    --shadow-card: 0px 0px 2px 0px rgba(145, 158, 171, 0.2), 0px 12px 24px -4px rgba(145, 158, 171, 0.12);
    --shadow-header: 0px 8px 16px 0px rgba(145, 158, 171, 0.16); /* Sombra suave al hacer scroll, por defecto flat */
    --radius-card: 16px;
}

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

body {
    font-family: "Public Sans", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scroll on mobile */
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-paper);
    border-right: 1px solid rgba(145, 158, 171, 0.24);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    z-index: 1100; /* Higher than everything */
    padding: 24px 20px;
    transition: transform 0.3s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    background: rgba(145, 158, 171, 0.12);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 20px;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto; /* Allow scroll in sidebar if menu is long */
}

.nav-item {
    
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.nav-link i {
    width: 24px;
    margin-right: 16px;
    font-size: 1.2rem;
}

.nav-link:hover {
    background-color: rgba(145, 158, 171, 0.08);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: rgba(0, 171, 85, 0.08); /* Verde muy suave */
    color: var(--primary-color);
}

.nav-link.active i {
    color: var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 88px 40px 40px 40px; /* Top padding para header */
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Header */
.header {
    height: var(--header-height);
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100% - var(--sidebar-width));
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Default for desktop */
    padding: 0 40px;
    transition: width 0.3s ease;
    /* border-bottom: 1px solid transparent; o sutil */
}

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

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(145, 158, 171, 0.08);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Page Titles */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 40px;
}

/* Grid System (Simple) */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

/* Cards */
.card {
    background: var(--bg-paper);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0px 8px 24px -4px rgba(145, 158, 171, 0.24);
}

/* Widgets Dashboard */
.widget {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* Colores específicos para widgets */
.widget.users { color: #005249; background-color: #C8FACD; } /* Tono verde */
.widget-icon.users { background: linear-gradient(135deg, rgba(0, 123, 85, 0) 0%, rgba(0, 123, 85, 0.24) 100%); color: #007B55; }

.widget.roles { color: #04297A; background-color: #D0F2FF; } /* Tono azul */
.widget-icon.roles { background: linear-gradient(135deg, rgba(12, 83, 183, 0) 0%, rgba(12, 83, 183, 0.24) 100%); color: #0C53B7; }

.widget.active { color: #7A4F01; background-color: #FFF7CD; } /* Tono amarillo */
.widget-icon.active { background: linear-gradient(135deg, rgba(183, 129, 3, 0) 0%, rgba(183, 129, 3, 0.24) 100%); color: #B78103; }

.widget.inactive { color: #7A0C2E; background-color: #FFE7D9; } /* Tono rojo */
.widget-icon.inactive { background: linear-gradient(135deg, rgba(183, 33, 54, 0) 0%, rgba(183, 33, 54, 0.24) 100%); color: #B72136; }


.widget-info h3 {
    font-size: 2rem;
    font-weight: 700;
}

.widget-info span {
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0.7;
}

/* Table Card */
.table-card {
    background: var(--bg-paper);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden; /* Para bordes redondeados */
}

.table-header {
    padding: 24px;
    border-bottom: 1px solid rgba(145, 158, 171, 0.24);
}

.table-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: #F4F6F8;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 16px;
    font-size: 0.875rem;
    white-space: nowrap; /* Prevent headers from wrapping too much */
}

td {
    padding: 16px;
    border-bottom: 1px solid rgba(145, 158, 171, 0.24);
    font-size: 0.875rem;
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: rgba(145, 158, 171, 0.08);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
}

.badge-admin { background-color: rgba(255, 72, 66, 0.16); color: rgb(183, 33, 54); }
.badge-editor { background-color: rgba(24, 144, 255, 0.16); color: rgb(12, 83, 183); }
.badge-user { background-color: rgba(145, 158, 171, 0.16); color: rgb(99, 115, 129); }

.status-dot {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-active { color: rgb(34, 154, 22); font-weight: 600; }
.status-inactive { color: rgb(183, 33, 54); font-weight: 600; }

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.875rem;
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 8px 16px rgba(0, 171, 85, 0.24);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: none;
}

.btn-secondary {
    background-color: #dfe3e8;
    color: #212b36;
}

.btn-secondary:hover {
    background-color: #c4cdd5;
}

.btn-danger {
    background-color: #FF4842;
    color: white;
    box-shadow: 0 8px 16px rgba(255, 72, 66, 0.24);
}

.btn-danger:hover {
    background-color: #B72136;
    box-shadow: none;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 1024px) {
    /* Sidebar hidden by default on mobile/tablet */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 8px 0 24px rgba(145, 158, 171, 0.24);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Main Content takes full width */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 80px 20px 20px 20px;
    }

    /* Header takes full width */
    .header {
        width: 100%;
        padding: 0 20px;
        justify-content: space-between; /* Space between toggle and actions */
    }

    /* Show toggle button */
    .menu-toggle {
        display: flex !important;
    }

    /* Adjust page title margin */
    .page-title {
        margin-bottom: 24px;
        font-size: 1.25rem;
    }

    /* Form Grids stack vertically */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Adjust cards padding */
    .card {
        padding: 20px;
    }

    /* Adjust header actions gap */
    .header-actions {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    /* Smaller adjustments for phones */
    .main-content {
        padding: 72px 16px 16px 16px;
    }

    .header {
        padding: 0 16px;
    }

    .brand-name {
        font-size: 1rem;
    }
    
    .btn {
        width: 100%; /* Full width buttons on mobile often better */
        margin-bottom: 8px;
    }
    
    .header-actions .icon-btn:first-child {
        display: none; /* Hide search on very small screens if needed */
    }
}
