:root {
    --primary-color: #d32f2f; /* Rojo principal */
    --primary-hover: #b71c1c;
    --bg-color: #f5f5f5;
    --text-color: #333;
    --text-secondary: #666;
    --white: #ffffff;
    --border-radius: 8px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    font-family: var(--font-family);
    color: var(--text-color);
    min-height: 100vh;
}

body:not(.dashboard-layout) {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    background-color: var(--white);
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.header {
    margin-bottom: 30px;
}

.logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.logo {
    max-width: 120px;
    height: auto;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-color);
}

.header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 22px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

input, select {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--white);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
    padding-right: 45px;
    cursor: pointer;
}

input:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(211, 47, 47, 0.15);
}

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.password-toggle {
    position: absolute;
    right: 15px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    z-index: 2;
}

.btn-login {
    width: 100%;
    padding: 18px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-login:hover {
    background-color: var(--primary-hover);
}

.msg-error {
    background-color: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    margin-bottom: 20px;
    font-weight: 600;
    border-left: 4px solid #c62828;
    display: none; /* Hidden by default */
}

.footer-links {
    margin-top: 25px;
}

.link-item {
    margin: 12px 0;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.footer-links a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

#soporte-link {
    color: var(--primary-color);
    font-weight: 700;
}

/* Mobile First Optimizations */
@media (max-width: 500px) {
    body {
        align-items: flex-start;
        background-color: var(--white);
        padding: 0;
    }

    .login-container {
        max-width: 100%;
        height: 100%;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        padding: 50px 25px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    input {
        padding: 18px;
        font-size: 1.15rem;
    }

    .btn-login {
        padding: 20px;
        font-size: 1.2rem;
    }
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    overflow-x: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background-color: #1a1a1a;
    color: var(--white);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 4000; /* Prioridad máxima sobre tablas */
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #333;
    gap: 12px;
}

.sidebar-logo {
    width: 32px;
    height: auto;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

.sidebar-nav-container {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 0 !important;
    margin: 0 !important;
}

.menu-item {
    margin-bottom: 4px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    width: 100%;
    color: #b3b3b3;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 12px;
}

.menu-link i {
    width: 20px;
}

.menu-link:hover, .menu-link.active {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--white);
}

.menu-link.active {
    border-left: 5px solid var(--primary-color) !important;
    background-color: rgba(211, 47, 47, 0.15) !important;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #333;
    font-size: 0.75rem;
    color: #666;
    text-align: center;
}

/* Main Header */
.main-header {
    height: 64px;
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 900;
    width: 100%;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: #f0f0f0;
}

.btn-icon.btn-edit { color: #f59e0b; }
.btn-icon.btn-delete { color: #ef4444; }
.btn-icon.btn-assign { color: #0369a1; } /* Blue for assignments */

.btn-icon.btn-edit:hover { background-color: #fef3c7; }
.btn-icon.btn-delete:hover { background-color: #fee2e2; }
.btn-icon.btn-assign:hover { background-color: #e0f2fe; }

.user-greeting {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 15px;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: #e0e0e0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 15px;
    border-radius: 6px;
    background-color: #fff1f1;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: var(--primary-color);
    color: var(--white);
}

/* Content Area */
.content-wrapper {
    padding: 30px;
}

.welcome-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: var(--white);
    padding: 40px;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: 0 10px 20px rgba(211, 47, 47, 0.2);
}

.welcome-card h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.welcome-card p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.stat-card {
    background-color: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background-color: #f0f0f0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.stat-info h3 {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Mobile Adjustments for Dashboard */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .hide-mobile {
        display: none;
    }

    .welcome-card {
        padding: 30px 20px;
    }

    .welcome-card h1 {
        font-size: 1.5rem;
    }
}

@media (min-width: 769px) {
    .main-content {
        margin-left: 260px;
    }

    .sidebar.hidden-desktop {
        transform: translateX(-100%) !important;
    }

    .main-content.expanded-desktop {
        margin-left: 0 !important;
    }
}
