/* 
 * WorkTion Lite - CSS Premium (Light Theme)
 * Mobile-First, Glass-morphism, Clean SaaS Aesthetic
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* TEMA CLARO */
    --bg-base: #f8fafc;
    /* slate-50 */
    --bg-panel: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-input: #ffffff;
    --bg-hover: rgba(15, 23, 42, 0.04);

    --text-primary: #0f172a;
    /* slate-900 */
    --text-secondary: #475569;
    /* slate-600 */
    --text-muted: #94a3b8;
    /* slate-400 */

    --border-color: rgba(15, 23, 42, 0.08);
    --border-focus: rgba(79, 70, 229, 0.5);

    /* Acentos Premium (Indigo/Cyan) */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #0ea5e9;
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--secondary));

    /* Estados / Roles */
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-text: #b91c1c;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-text: #047857;
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-text: #b45309;
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --info-text: #1d4ed8;
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.1);
    --amber-text: #b45309;
    --indigo: #6366f1;
    --indigo-bg: rgba(99, 102, 241, 0.1);
    --indigo-text: #4338ca;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.05);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
    /* App takes full height, scroll inside containers */
}

h1,
h2,
h3,
h4 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

p {
    color: var(--text-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

ul {
    list-style: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

/* ===== BACKGROUND ORBS (Desactivados por ser light, uso SVG base) ===== */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    /* A subtle top gradient to mimic a premium light feel without heavy orbs */
    background: radial-gradient(circle at 50% 0%, #e0e7ff 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, #cffafe 0%, transparent 50%);
}

/* ===== GRID LAYOUT (Mobile First) ===== */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ===== HEADER MOBILE ===== */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 1rem;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 40;
}

.mobile-header .logo-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.menu-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== SIDEBAR (Drawer in Mobile, Fixed in Desktop) ===== */
#sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: var(--shadow-glass);
}

#sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.sidebar-header {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-sidebar-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background: var(--bg-hover);
    color: var(--primary);
}

.nav-item.active {
    border-left-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.nav-item i {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    overflow: hidden;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
}

.logout-btn:hover {
    color: var(--danger);
    transform: scale(1.1);
}

/* ===== MAIN CONTENT ===== */
#main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    padding-bottom: 80px;
    /* Space for bottom nav */
    scroll-behavior: smooth;
}

.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ===== BOTTOM NAVIGATION (Mobile Only) ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}

.bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 0.5rem;
    flex: 1;
    transition: var(--transition);
}

.bnav-item i {
    font-size: 1.25rem;
    transition: transform 0.2s;
}

.bnav-item.active {
    color: var(--primary);
}

.bnav-item.active i {
    transform: translateY(-2px);
}

/* ===== DESKTOP LAYOUT (> 768px) ===== */
@media (min-width: 768px) {
    #app-container {
        flex-direction: row;
    }

    .mobile-header {
        display: none;
    }

    .bottom-nav {
        display: none;
    }

    #sidebar {
        position: static;
        left: 0;
        height: 100vh;
        flex-shrink: 0;
        box-shadow: none;
        border-right: 1px solid var(--border-color);
    }

    .sidebar-overlay {
        display: none;
    }

    .close-sidebar-btn {
        display: none;
    }

    #main-content {
        padding: 2.5rem;
        padding-bottom: 2.5rem;
    }

    .page-header {
        margin-bottom: 2rem;
    }

    .page-title {
        font-size: 2rem;
    }
}

/* ===== LOGIN PAGE ===== */
#login-page {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: 1rem;
    z-index: 100;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-glass);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-card .logo {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ===== FORMS & INPUTS ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    min-height: 48px;
    /* Touch target */
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    min-height: 48px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.23);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--border-color);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    min-height: 32px;
    border-radius: 6px;
}

/* ===== STAT CARDS (Dashboard) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== LIST CARDS (Empleados / Áreas) ===== */
.card-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .card-list {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: var(--transition);
}

.item-card:hover {
    border-color: var(--primary);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.item-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.item-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.item-body {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-amber {
    background: var(--amber-bg);
    color: var(--amber-text);
}

.badge-blue {
    background: var(--info-bg);
    color: var(--info-text);
}

.badge-indigo {
    background: var(--indigo-bg);
    color: var(--indigo-text);
}

.badge-green {
    background: var(--success-bg);
    color: var(--success-text);
}

/* ===== TABS ===== */
.tabs-container {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== TASK CARDS ===== */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.task-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.task-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

/* ===== TABLE (Desktop Activity) ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th,
td {
    padding: 1rem 1.5rem;
    text-align: left;
}

th {
    background: rgba(15, 23, 42, 0.02);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    font-size: 0.9rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-input);
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    border-radius: var(--radius-lg);
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* ===== TOASTS ===== */
#toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
}

@media (min-width: 768px) {
    #toast-container {
        bottom: 2rem;
        right: 2rem;
        left: auto;
        transform: none;
        align-items: flex-end;
    }
}

.toast {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: all;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast i {
    font-size: 1.1rem;
}

.toast.success i {
    color: var(--success);
}

.toast.error i {
    color: var(--danger);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== UTILS ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.empty-state {
    padding: 4rem 1rem;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.5;
    color: var(--primary);
}

/* Camera Modal Fix */
#camera-modal .modal-content {
    max-width: 600px;
    padding: 1.5rem;
}

#camera-preview {
    width: 100%;
    border-radius: var(--radius-md);
    background: #000;
    max-height: 60vh;
    object-fit: cover;
}