/* ============================================
   PREVENTA MÓVIL - DISEÑO MODERNO RESPONSIVE
   ============================================ */

/* Variables CSS - Light Mode */
:root {
    --primary: #007BFF;
    --primary-dark: #0056b3;
    --primary-light: #e0f2ff;

    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --sidebar-start: #1e3a8a;
    --sidebar-end: #3b82f6;

    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-white: #ffffff;

    --text-main: #1f2937;
    --text-sub: #6b7280;
    --text-muted: #9ca3af;

    --border-color: #e5e7eb;
    --border-light: #f3f4f6;

    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --header-height: 64px;
    --sidebar-width: 256px;
    --border-radius: 0.5rem;
    --border-radius-lg: 1rem;
    --transition-fast: 200ms;
    --transition-normal: 300ms;
}

/* Variables CSS - Dark Mode */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --primary-light: #1e3a5f;

    --success: #22c55e;
    --success-light: #14532d;
    --danger: #f87171;
    --danger-light: #7f1d1d;
    --warning: #fbbf24;
    --warning-light: #78350f;
    --info: #60a5fa;
    --info-light: #1e3a8a;

    --sidebar-start: #0f172a;
    --sidebar-end: #1e3a8a;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-white: #1e293b;

    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-light: #1e293b;

    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* Reset y Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
    overflow: hidden;
}

/* Material Icons */
.material-icons-round {
    font-family: 'Material Icons Round';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-start);
    background-image: linear-gradient(180deg, var(--sidebar-start) 0%, var(--sidebar-end) 100%);
    background: linear-gradient(180deg, var(--sidebar-start) 0%, var(--sidebar-end) 100%);
    color: white;
    flex-shrink: 0;
    display: none;
    flex-direction: column;
    z-index: 30;
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo .material-icons-round {
    font-size: 2rem;
}

.sidebar-logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.025em;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-link .material-icons-round {
    font-size: 1.375rem;
}

.nav-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    padding: 0.75rem 1rem 0.25rem;
    margin-top: 0.25rem;
    list-style: none;
}

.sidebar-footer {
    padding: 1.5rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-theme-toggle {
    display: flex;
    justify-content: center;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Mobile Header */
.mobile-header {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--primary);
    color: white;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 40;
    box-shadow: var(--shadow-md);
}

.mobile-header-title {
    font-weight: 600;
    font-size: 1.125rem;
}

.mobile-header .menu-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: background-color var(--transition-fast);
}

.mobile-header .menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Desktop Header */
.desktop-header {
    display: none;
    height: 80px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-soft);
}

.header-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-sub);
    font-size: 0.875rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-main);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-sub);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow-md);
    border: 2px solid white;
}

/* Main Content */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding-top: var(--header-height);
}

.content-wrapper {
    padding: 1.5rem 1rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 25;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Mobile Sidebar Open State */
.app-layout.sidebar-open .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    animation: slideIn var(--transition-normal) ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* ============================================
   COMPONENTES UI
   ============================================ */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    color: white;
    background-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    color: var(--text-main);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-success {
    color: white;
    background-color: var(--success);
}

.btn-danger {
    color: white;
    background-color: var(--danger);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
}

/* Cards */
.card {
    background-color: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1rem 1.25rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* Stat Cards */
.stat-card {
    background-color: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    padding: 1.25rem;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.primary {
    background-color: var(--info-light);
    color: var(--info);
}

.stat-card-icon.success {
    background-color: var(--success-light);
    color: var(--success);
}

.stat-card-icon.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.stat-card-icon.info {
    background-color: #f3f4f6;
    color: var(--text-sub);
}

.stat-card-trend {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
}

.stat-card-trend.up {
    background-color: var(--success-light);
    color: var(--success);
}

.stat-card-trend.down {
    background-color: var(--danger-light);
    color: var(--danger);
}

.stat-card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.stat-card-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-sub);
}

/* Form Controls */
.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-sub);
}

.form-group {
    margin-bottom: 1rem;
}

/* Search Bar */
.search-bar {
    position: relative;
}

.search-bar .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-bar .form-control {
    padding-left: 2.75rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    color: white;
    background-color: var(--primary);
}

.badge-success {
    color: var(--success);
    background-color: var(--success-light);
}

.badge-warning {
    color: var(--warning);
    background-color: var(--warning-light);
}

.badge-danger {
    color: var(--danger);
    background-color: var(--danger-light);
}

.badge-secondary {
    color: var(--text-sub);
    background-color: var(--bg-secondary);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-danger {
    color: #991b1b;
    background-color: var(--danger-light);
    border: 1px solid #fecaca;
}

.alert-success {
    color: #166534;
    background-color: var(--success-light);
    border: 1px solid #a7f3d0;
}

.alert-warning {
    color: #92400e;
    background-color: var(--warning-light);
    border: 1px solid #fde68a;
}

.alert-info {
    color: #1e40af;
    background-color: var(--info-light);
    border: 1px solid #bfdbfe;
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    border-color: var(--success);
}

.invalid {
    border-color: var(--danger);
}

.validation-message, .text-danger {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Lists */
.list-group {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-group-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    gap: 1rem;
    transition: background-color var(--transition-fast);
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item-action {
    cursor: pointer;
}

.list-group-item-action:hover {
    background-color: var(--bg-secondary);
}

/* Avatar */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.avatar-indigo {
    background-color: #e0e7ff;
    color: #4338ca;
}

.avatar-blue {
    background-color: var(--info-light);
    color: var(--info);
}

.avatar-green {
    background-color: var(--success-light);
    color: var(--success);
}

/* Action Buttons Grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem;
    min-height: 140px;
    background-color: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text-main);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.action-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-main);
}

.action-card-primary {
    background-color: var(--primary);
    color: white;
    border: none;
}

.action-card-primary:hover {
    background-color: var(--primary-dark);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.action-card-success {
    background-color: var(--success);
    color: white;
    border: none;
}

.action-card-success:hover {
    filter: brightness(0.9);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.action-card-success .action-card-icon {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.action-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.action-card:not(.action-card-primary):not(.action-card-success) .action-card-icon {
    background-color: var(--bg-secondary);
    color: var(--text-sub);
}

.action-card-primary .action-card-icon {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.action-card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.action-card-subtitle {
    font-size: 0.8125rem;
    opacity: 0.8;
}

/* ============================================
   UTILIDADES
   ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.fw-bold { font-weight: 600; }
.fw-medium { font-weight: 500; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.d-flex { display: flex; }
.d-none { display: none; }
.d-block { display: block; }

.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.w-100 { width: 100%; }

/* Spinner */
.spinner-border {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 1.5px;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    color: var(--text-sub);
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: 0.875rem;
    max-width: 300px;
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Blazor Error UI */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background-color: var(--danger);
    color: white;
    padding: 1rem;
}

#blazor-error-ui .error-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

#blazor-error-ui .reload {
    color: white;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: white;
    border-radius: var(--border-radius);
}

.blazor-error-boundary::after {
    content: "Ha ocurrido un error. Por favor recargue la página.";
}

/* Focus States */
.btn:focus,
.form-control:focus,
.form-check-input:focus {
    outline: none;
}

h1:focus {
    outline: none;
}

/* Scroll */
html {
    scroll-behavior: smooth;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ============================================
   RESPONSIVE - TABLET (768px+)
   ============================================ */
@media (min-width: 768px) {
    .content-wrapper {
        padding: 2rem;
    }

    .action-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   RESPONSIVE - DESKTOP (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    .sidebar {
        display: flex;
    }

    .mobile-header {
        display: none;
    }

    .desktop-header {
        display: flex;
    }

    .main-content {
        padding-top: 0;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .app-layout.sidebar-open .sidebar {
        position: static;
        animation: none;
    }
}
