/* V-Active Modern Minimalist Theme */
:root {
    /* --- PALETA DE COLORES (Ajustar según logo_tecnocas.png) --- */
    --primary: #0f172a;
    /* Color principal (ej. Texto oscuro, Sidebar) */
    --primary-light: #334155;
    /* Variación más clara */
    --accent: #f97316;
    /* Color de acento (ej. Naranja del logo) */
    --secondary: #64748b;
    /* Gris para textos secundarios */

    /* Fondos */
    --bg-body: #f1f5f9;
    /* Fondo general (Gris muy suave) */
    --bg-surface: #ffffff;
    /* Fondo de tarjetas y sidebar */
    --bg-hover: #f8fafc;

    /* Estados */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --border: #e2e8f0;

    /* UI */
    --radius: 12px;
    /* Bordes redondeados modernos */
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --header-height: 64px;
    --sidebar-width: 260px;
}

/* --- MODO OSCURO --- */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-hover: #334155;
    --border: #334155;
}

body.dark-mode,
body.dark-mode .card h2,
body.dark-mode label,
body.dark-mode .table td,
body.dark-mode .icon-wrapper {
    color: #f8fafc;
}

body.dark-mode .sidebar-menu a {
    color: #94a3b8;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    color: #f8fafc;
}

body.dark-mode .btn-secondary {
    background-color: var(--bg-surface);
    color: #f8fafc;
}

body.dark-mode .table th {
    color: #94a3b8;
}

body.dark-mode .auth-card {
    background: var(--bg-surface);
    border-color: var(--border);
}

body.dark-mode .text-muted,
body.dark-mode p {
    color: #94a3b8;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--primary);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--info);
    transition: color 0.2s;
}

a:hover {
    color: var(--primary);
}

/* --- LAYOUT --- */
.dashboard-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: width 0.3s ease;
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar.collapsed .menu-text {
    display: none;
}

.sidebar.collapsed .sidebar-menu a {
    padding-left: 0 !important;
    justify-content: center;
}

.sidebar.collapsed .sidebar-menu i {
    margin-right: 0;
    font-size: 1.4em;
}

.sidebar.collapsed .sidebar-search a {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .sidebar-search i {
    margin-right: 0;
}

.sidebar.collapsed .logo-vactive {
    display: none;
}

.sidebar.collapsed .lang-flags {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center !important;
    padding: 1rem !important;
}

/* Tooltip styles for collapsed sidebar */
.sidebar.collapsed a[data-title] {
    position: relative;
}

.sidebar.collapsed a[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background-color: #333;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    margin-left: 10px;
    font-size: 0.85rem;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    font-weight: normal;
}

.sidebar.collapsed a[data-title]:hover::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: transparent #333 transparent transparent;
    margin-left: 0px;
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

.sidebar-header {
    border-bottom: 1px solid var(--border);
}

.sidebar-header img {
    max-height: 50px;
    width: auto;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-menu li {
    margin-bottom: 4px;
    padding: 0 1rem;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--secondary);
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background-color: var(--bg-body);
    color: var(--accent);
}

.sidebar-menu i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    font-size: 1.1em;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    overflow: hidden;
    position: relative;
}

.top-bar {
    background: var(--bg-surface);
    height: var(--header-height);
    padding: 0 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* --- COMPONENTES --- */
/* Cards */
.card {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.card h2 {
    margin-top: 0;
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* Botones */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    color: var(--secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--bg-body);
    color: var(--primary);
    border-color: var(--secondary);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

/* Formularios */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-body);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* Tablas */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
}

.table th {
    background: var(--bg-body);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--secondary);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--primary);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: var(--bg-hover);
}

/* Alertas */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
    font-weight: 500;
}

.alert.success {
    background-color: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert.warning {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 999px;
    color: #fff;
    background-color: var(--secondary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    background: var(--bg-body);
    color: var(--primary);
}

.auth-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-body);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    padding: 1.5rem 1.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    max-height: 92vh;
    overflow-y: auto;
}

.auth-card h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
}

.auth-card .form-group {
    margin-bottom: 0.85rem;
}

.auth-card label {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.auth-card input,
.auth-card select,
.auth-card textarea {
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 1rem;
}

.auth-header img {
    max-height: 40px;
    max-width: 130px;
    margin-bottom: 0.5rem;
    object-fit: contain;
}

.toggle-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    color: var(--accent);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Tree View */
ul.tree,
ul.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.tree ul {
    margin-left: 1.5rem;
    border-left: 2px solid var(--border);
}

ul.tree li {
    margin: 0.5rem 0;
    position: relative;
}

.tree-item-content {
    background: var(--bg-surface);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s;
}

.tree-item-content:hover {
    border-color: var(--accent);
}

.caret {
    cursor: pointer;
    user-select: none;
    margin-right: 8px;
    color: var(--secondary);
    width: 20px;
    display: inline-block;
    text-align: center;
    transition: transform 0.2s;
}

.caret-down {
    transform: rotate(90deg);
}

.nested {
    display: none;
}

.active {
    display: block;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    margin-top: auto;
}

/* Responsive Mobile Sidebar Hide */
@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }

    .top-bar {
        padding: 0 1rem;
    }

    .sidebar {
        display: none !important;
    }
}