/**
 * Sistema de Gestión - Estilos Principales
 * Tema claro/oscuro con paletas de colores personalizables
 */

/* ========== Variables de Tema ========== */
:root {
    /* Colores base - Tema Claro */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --border-color: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);

    /* Colores de estado */
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --danger-color: #f56565;
    --info-color: #4299e1;

    /* Paleta primaria - Azul por defecto */
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --primary-light: #e9ecff;
}

/* Tema Oscuro */
[data-theme-mode="dark"] {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #4a5568;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-tertiary: #cbd5e0;
    --border-color: #4a5568;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
}

/* Paletas de colores regulares */
[data-color-theme="blue"] {
    --primary-color: #2563eb;
    --primary-hover: #1e40af;
    --primary-light: #dbeafe;
}
[data-color-theme="green"] {
    --primary-color: #16a34a;
    --primary-hover: #15803d;
    --primary-light: #dcfce7;
}
[data-color-theme="purple"] {
    --primary-color: #9333ea;
    --primary-hover: #7c3aed;
    --primary-light: #f3e8ff;
}
[data-color-theme="red"] {
    --primary-color: #dc2626;
    --primary-hover: #b91c1c;
    --primary-light: #fee2e2;
}
[data-color-theme="orange"] {
    --primary-color: #ea580c;
    --primary-hover: #c2410c;
    --primary-light: #ffedd5;
}

/* Paletas de colores pasteles */
[data-color-theme="pastel-pink"] {
    --primary-color: #f06292;
    --primary-hover: #ec407a;
    --primary-light: #fce4ec;
}
[data-color-theme="pastel-blue"] {
    --primary-color: #64b5f6;
    --primary-hover: #42a5f5;
    --primary-light: #e3f2fd;
}
[data-color-theme="pastel-green"] {
    --primary-color: #81c784;
    --primary-hover: #66bb6a;
    --primary-light: #e8f5e9;
}
[data-color-theme="pastel-purple"] {
    --primary-color: #ba68c8;
    --primary-hover: #ab47bc;
    --primary-light: #f3e5f5;
}
[data-color-theme="pastel-yellow"] {
    --primary-color: #ffd54f;
    --primary-hover: #ffca28;
    --primary-light: #fffde7;
}

/* ========== Reset y Base ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

/* ========== Login Container ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(
        135deg,
        var(--primary-color) 0%,
        var(--primary-hover) 100%
    );
}

.login-form {
    background: var(--bg-primary);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow);
    width: 100%;
    max-width: 450px;
}

.login-form h2 {
    margin-bottom: 30px;
    color: var(--text-primary);
    text-align: center;
    font-size: 28px;
}

/* ========== Formularios ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

button[type="submit"],
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

button[type="submit"]:hover,
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

button[type="submit"]:active,
.btn-primary:active {
    transform: translateY(0);
}

/* ========== Mensajes ========== */
.error-message,
.success-message,
.info-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.error-message {
    background-color: #fee;
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

.success-message {
    background-color: #efe;
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.info-message {
    background-color: #eff6ff;
    color: var(--info-color);
    border-left: 4px solid var(--info-color);
}

.login-info {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

.login-info p {
    margin: 4px 0;
}

/* ========== Dashboard Layout ========== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 24px;
    color: var(--primary-color);
}

.sidebar-nav {
    margin-top: 20px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin: 4px 0;
}

.sidebar-nav a {
    display: block;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.sidebar-nav a.active {
    background: var(--primary-light);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 20px;
    background: var(--bg-secondary);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.header h2 {
    font-size: 28px;
    color: var(--text-primary);
}

.logout-btn {
    padding: 10px 20px;
    background: var(--danger-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

.menu-toggle {
    display: none;
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

/* ========== Speech Bubble ========== */
.speech-bubble {
    background: var(--info-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    position: relative;
    margin-bottom: 20px;
    font-size: 14px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .header {
        flex-wrap: wrap;
    }

    .header h2 {
        order: 2;
        width: 100%;
        margin-top: 12px;
        font-size: 22px;
    }
}

/* ========== Contenido de Dashboard ========== */
.content {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
    margin-bottom: 20px;
}

.content h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* ========== Botones Mejorados ========== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    vertical-align: middle;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: auto;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.3);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #dd6b20;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(237, 137, 54, 0.3);
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
}

.btn-secondary {
    background: var(--text-tertiary);
    color: white;
}

.btn-secondary:hover {
    background: var(--text-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    border-radius: 10px;
}

/* ========== Aplicaciones Grid ========== */
.apps-section {
    margin-bottom: 30px;
}

.apps-section h3 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 22px;
}

.apps-section h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.app-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px var(--shadow);
}

.app-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-hover);
    border-color: var(--primary-color);
}

.app-card h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 18px;
    line-height: 1.4;
}

.app-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.app-actions {
    margin-top: 20px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: var(--text-tertiary);
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorite-btn:hover {
    background: var(--bg-secondary);
    color: var(--warning-color);
    transform: scale(1.1);
}

.favorite-btn.active {
    color: var(--warning-color);
}

.app-card.favorite {
    border: 2px solid var(--warning-color);
    background: linear-gradient(
        135deg,
        var(--bg-primary) 0%,
        rgba(237, 137, 54, 0.05) 100%
    );
}

.no-apps {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    color: var(--text-secondary);
}

/* ========== Tablas ========== */
.table-container {
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px var(--shadow);
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th,
table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

table td {
    color: var(--text-secondary);
    vertical-align: middle;
}

table tr:hover {
    background: var(--bg-secondary);
}

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

/* ========== Acciones de Tabla ========== */
.apps-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== Estados de Usuario ========== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.status-inactive {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger-color);
}

.status-blocked {
    background: rgba(237, 137, 54, 0.1);
    color: var(--warning-color);
}

/* ========== Estadísticas de Inicio ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-card {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-card h4 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-weight: 700;
}

.stat-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

/* ========== Formularios Mejorados ========== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.form-section {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
}

.form-section h4 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 18px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* ========== Responsivo para Tablas ========== */
@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
    }

    table,
    table thead,
    table tbody,
    table th,
    table td,
    table tr {
        display: block;
    }

    table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    table tr {
        border: 1px solid var(--border-color);
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 8px;
        background: var(--bg-primary);
    }

    table td {
        border: none;
        position: relative;
        padding: 12px 12px 12px 35%;
        text-align: left;
    }

    table td:before {
        content: attr(data-label) ": ";
        position: absolute;
        left: 12px;
        width: 30%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-primary);
    }

    .apps-actions,
    .user-actions {
        justify-content: flex-start;
        margin-top: 8px;
    }

    .apps-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    .btn {
        font-size: 12px;
        padding: 10px 16px;
    }

    .btn-sm {
        font-size: 11px;
        padding: 6px 12px;
    }

    .content {
        padding: 20px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .header h2 {
        order: 1;
        font-size: 24px;
    }

    .logout-btn {
        order: 2;
    }

    .menu-toggle {
        order: 0;
        align-self: flex-start;
    }
}

/* ========== Utilidades ========== */
.text-center {
    text-align: center;
}
.text-left {
    text-align: left;
}
.text-right {
    text-align: right;
}
.mt-1 {
    margin-top: 8px;
}
.mt-2 {
    margin-top: 16px;
}
.mt-3 {
    margin-top: 24px;
}
.mb-1 {
    margin-bottom: 8px;
}
.mb-2 {
    margin-bottom: 16px;
}
.mb-3 {
    margin-bottom: 24px;
}
.ml-1 {
    margin-left: 8px;
}
.ml-2 {
    margin-left: 16px;
}
.mr-1 {
    margin-right: 8px;
}
.mr-2 {
    margin-right: 16px;
}
.p-1 {
    padding: 8px;
}
.p-2 {
    padding: 16px;
}
.p-3 {
    padding: 24px;
}
.w-full {
    width: 100%;
}
.flex {
    display: flex;
}
.flex-wrap {
    flex-wrap: wrap;
}
.items-center {
    align-items: center;
}
.justify-between {
    justify-content: space-between;
}
.justify-center {
    justify-content: center;
}
.gap-1 {
    gap: 8px;
}
.gap-2 {
    gap: 16px;
}
.gap-3 {
    gap: 24px;
}
