:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);

    --font-main: 'Inter', sans-serif;
}

/* Animations */
@keyframes blink {
    0% {
        opacity: 0.2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

.typing-dots span {
    animation-name: blink;
    animation-duration: 1.4s;
    animation-iteration-count: infinite;
    animation-fill-mode: both;
    font-size: 24px;
    line-height: 10px;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

:root {
    /* Colors */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Spacing & Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    --font-inter: 'Inter', sans-serif;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-inter);
    background-color: var(--background);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll usually */
}

/* Ensure no horizontal scroll on mobile */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        /* Allow vertical scroll on mobile body if needed */
        overflow-x: hidden;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

.full-width {
    width: 100%;
}

.center {
    justify-content: center;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f1f5f9;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Loading Overlay (New) */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.login-card {
    background-color: white;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    font-weight: 500;
}

/* Branding (New) */
.branding {
    text-align: center;
    margin-bottom: 3rem;
    /* Increased from 2rem to add more space before "Iniciar Sesión" */
}

.main-logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    /* Space between Title and Sub-brand */
}

.sub-brand {
    font-size: 0.75rem;
    /* Smaller */
    color: var(--text-muted);
    text-decoration: none;
    display: block;
    /* Ensure it takes full width to center properly */
    transition: color 0.2s;
}

.sub-brand:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}


/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2rem;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary);
}

.sidebar-footer {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.75rem;
}

.dev-link {
    color: var(--text-muted);
    text-decoration: none;
}

.dev-link:hover {
    text-decoration: underline;
    color: var(--primary);
}

/* User Select - Sidebar (Hidden via JS if logic dictates, but we keep it for switching context) */
.user-select-container {
    margin-bottom: 2rem;
}

.user-select-container label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    background-color: #f8fafc;
    color: var(--text-main);
    cursor: pointer;
}

.user-select:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}


.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.nav-links li.active button {
    background-color: #eff6ff;
    /* light blue bg */
    color: var(--primary);
}

.nav-links button:hover {
    background-color: #f8fafc;
    color: var(--primary-dark);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.icon-btn:hover {
    background-color: #f1f5f9;
    color: var(--danger);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

.view.hidden {
    display: none;
}

/* Specific override */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.top-bar h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.date-display {
    color: var(--text-muted);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.status-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--secondary);
}

.status-badge.working .dot {
    background-color: var(--success);
}

.status-badge.working .text {
    color: var(--success);
}

.status-badge.paused .dot {
    background-color: var(--warning);
}

.status-badge.paused .text {
    color: var(--warning);
}

/* Clock Card */
.clock-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.time-display {
    font-size: 4rem;
    font-weight: 700;
    font-feature-settings: "tnum";
    color: var(--text-main);
    margin-bottom: 2rem;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    font-family: inherit;
    color: var(--text-main);
    /* Default text color */
}

.action-btn:active {
    transform: scale(0.98);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.primary {
    background-color: var(--primary);
    color: white;
}

.action-btn.warning {
    background-color: #fffbeb;
    color: var(--warning);
    border: 1px solid #fcd34d;
}

.action-btn.danger {
    background-color: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background-color: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-box.blue {
    background-color: #eff6ff;
    color: var(--primary);
}

.icon-box.purple {
    background-color: #f5f3ff;
    color: #8b5cf6;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-info .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-info .value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Tables */
.table-container {
    background-color: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th {
    background-color: #f8fafc;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.empty-state {
    padding: 4rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

/* Settings */
.settings-grid {
    display: grid;
    gap: 2rem;
    max-width: 600px;
}

.card {
    background-color: var(--surface);
    padding: 2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background-color: white;
}

.secondary-btn,
.primary-btn,
.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
    color: var(--text-main);
}

.primary-btn {
    background-color: var(--primary);
    color: white;
}

.secondary-btn {
    background-color: white;
    border: 1px solid var(--border);
}

.danger-btn.outline {
    background-color: white;
    border: 1px solid #fecaca;
    color: var(--danger);
}

.secondary-btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.danger-btn:hover {
    background-color: #fef2f2;
}

.actions-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Team List New */
.team-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.team-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.team-item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.team-item-avatar {
    width: 32px;
    height: 32px;
    background-color: #cbd5e1;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.add-user-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.add-user-form input,
.add-user-form select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 100px;
}

/* Messaging System */
.badge-counter {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 99px;
    margin-left: 8px;
    vertical-align: middle;
}

.msg-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.msg-card.unread {
    border-left: 4px solid #ef4444;
    background: #fff1f2;
}

.msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-weight: 500;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 1rem;
        justify-content: space-between;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
        z-index: 10;
        flex-shrink: 0;
    }

    .user-select-container {
        display: none;
    }

    .logo {
        display: none !important;
    }

    .user-profile {
        flex-direction: row;
    }

    .user-profile .user-info {
        display: none;
    }

    .user-profile .icon-btn {
        margin-left: 0;
    }

    .nav-links {
        display: flex;
        gap: 0.5rem;
        margin: 0;
    }

    .nav-links li {
        margin: 0;
    }

    .nav-links button span {
        display: none;
    }

    .nav-links button {
        padding: 0.75rem;
    }

    .main-content {
        padding: 1.5rem;
        height: calc(100vh - 70px);
    }

    .time-display {
        font-size: 15vw;
        /* Responsive font size for clock */
    }

    .clock-card {
        padding: 2rem 1.5rem;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
    }

    .sidebar-footer {
        display: none;
    }

    /* Fix Chat Window on Mobile */
    .chat-window {
        right: 5% !important;
        left: 5% !important;
        width: 90% !important;
        bottom: 5rem !important;
        /* Above nav if bottom nav exists, or just above bottom */
        height: 60vh !important;
    }

    /* Fix Modals on Mobile */
    .email-compose-window,
    .login-card,
    #editShiftModal .email-compose-window {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        margin: 10px auto;
    }

    /* --- Mobile History View (Card Layout) --- */
    /* Force table to not be a table anymore */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }

    /* Hide Table Headers */
    .data-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .data-table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 1rem;
        background: white;
        box-shadow: var(--shadow-sm);
    }

    .data-table td {
        /* Behave like a "row" */
        border: none;
        border-bottom: 1px solid #f1f5f9;
        position: relative;
        padding-left: 45% !important;
        padding-right: 1rem !important;
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        text-align: right;
        /* Value on the right */
        white-space: normal !important;
        /* Allow wrapping */
        min-height: 40px;
    }

    .data-table td:last-child {
        border-bottom: none;
    }

    .data-table td:before {
        /* Now like a table header */
        position: absolute;
        /* Top/Left values mimic padding */
        top: 0.75rem;
        left: 1rem;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
        content: attr(data-label);
    }

    /* Filters Stack */
    .filters-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    .filters-container input,
    .filters-container select,
    .filters-container button {
        width: 100% !important;
        margin: 0 !important;
    }
}


/* Chat Widget Styles */
.chat-widget-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.2s,
        background-color 0.2s;
    z-index: 1000;
    border: none;
}

.chat-widget-btn:hover {
    transform: scale(1.05);
    background-color: var(--primary-dark);
}

.chat-window {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: opacity 0.2s, transform 0.2s;
    transform-origin: bottom right;
}

.chat-window.hidden {
    display: none;
    opacity: 0;
    transform: scale(0.9);
}

.chat-header {
    padding: 1rem;
    background-color: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.8;
}

.chat-close-btn:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #f8fafc;
}

.chat-message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-message.bot {
    align-self: flex-start;
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.chat-message.user {
    align-self: flex-end;
    background-color: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background-color: white;
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

.chat-input:focus {
    border-color: var(--primary);
}

.chat-send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
}

.chat-send-btn:disabled {
    background-color: var(--border);
    cursor: not-allowed;
}

/* Hide footer on mobile sidebar to save space */
@media (max-width: 768px) {
    .sidebar-footer {
        display: none;
    }
}

/* Email Compose Window (Outlook Express Style) */
.email-compose-window {
    background: white;
    border-radius: 8px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    width: 600px;
    max-width: 95%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 500px;
    animation: slideUp 0.3s ease-out;
}

.email-window-header {
    background: #0f172a;
    /* Dark header like window title bar */
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.email-window-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.8;
    padding: 2px;
}

.email-window-header button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.email-toolbar {
    background: #f1f5f9;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
}

.toolbar-btn {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.toolbar-btn:active {
    transform: translateY(1px);
}

.email-rect-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.email-rect-row label {
    width: 60px;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 500;
}

.email-rect-row .input-wrapper {
    flex: 1;
}

.email-rect-row select {
    width: 100%;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    background: transparent;
    cursor: pointer;
}

.email-body-area {
    flex: 1;
    padding: 1rem;
    background: white;
    display: flex;
    flex-direction: column;
}

.email-body-area textarea {
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    color: #1e293b;
    line-height: 1.5;
}

/* Calendar Tool Btn */
.cal-tool-btn {
    opacity: 0.6;
    transition: all 0.2s;
    transform: scale(1);
}

.cal-tool-btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.cal-tool-btn.active {
    opacity: 1 !important;
    transform: scale(1.05);
    box-shadow: 0 0 0 2px #0f172a !important;
    /* Ring effect */
    z-index: 10;
}

/* Report Controls & Print Styles */
.report-controls {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: wrap;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.report-controls .control-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.report-controls label {
    font-weight: 500;
    color: var(--text-heading);
    font-size: 0.9rem;
}

.report-controls select,
.report-controls input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
}

@media print {

    /* Reset Body */
    body {
        background: white;
        margin: 0;
        padding: 0;
        font-family: Arial, sans-serif;
    }

    /* Hide Everything by Default */
    .sidebar,
    .top-bar,
    .view-header,
    .report-controls,
    .controls,
    .status-badge,
    #chatWidgetBtn,
    #chatWindow,
    #loginOverlay,
    button {
        display: none !important;
    }

    /* Structure Resets */
    .app-container,
    .main-content {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .view-section,
    #reports {
        display: block !important;
        visibility: visible !important;
        height: auto !important;
        opacity: 1 !important;
        padding: 0 !important;
    }

    /* Visible Report Content */
    .reports-container,
    .table-container {
        display: block !important;
        visibility: visible !important;
        overflow: visible !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Print Header */
    .print-only {
        display: block !important;
    }

    /* Table Styles */
    .data-table {
        width: 100%;
        border-collapse: collapse;
        border: 1px solid #000;
    }

    .data-table th,
    .data-table td {
        border: 1px solid #ccc;
        padding: 6px;
        font-size: 11px;
        color: black;
    }

    .data-table th {
        background-color: #eee !important;
        -webkit-print-color-adjust: exact;
    }

    /* Hide Tooltips on Print */
    [title] {
        position: static !important;
    }
}

/* --- Reports Module --- */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

.report-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.report-card i {
    font-size: 2.5rem;
    color: var(--primary);
}

.report-card h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.report-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-light);
}

.report-container {
    padding: 20px;
}

.report-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.report-paper {
    background: white;
    max-width: 210mm;
    /* A4 width */
    min-height: 297mm;
    /* A4 height */
    margin: 0 auto;
    padding: 20mm;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .sidebar,
    .mobile-header,
    .no-print,
    .header,
    .view-section:not(#reportsView) {
        display: none !important;
    }

    .view-section#reportsView {
        display: block !important;
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
        background: white;
    }

    .report-actions,
    .reports-grid,
    #reportsView>header {
        display: none !important;
    }

    .report-container {
        display: block !important;
        padding: 0;
        margin: 0;
    }

    .report-paper {
        box-shadow: none;
        padding: 0;
        margin: 0;
        width: 100%;
        max-width: none;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    /* Table Print Fixes */
    table {
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }
}

/* --- PWA Theme (Blue "Euskal" Style) --- */
.pwa-theme {
    background: linear-gradient(135deg, #7DD3FC 0%, #38BDF8 100%);
    /* Light Sky Blue Gradient */
    min-height: 100vh;
}

.pwa-theme .login-overlay {
    background: linear-gradient(135deg, #7DD3FC 0%, #38BDF8 100%);
    /* Opaque Gradient to hide app behind */
    padding: 20px;
}

/* Enhanced Login Card for PWA */
.pwa-theme .login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: none;
    max-width: 450px;
    width: 90%;
}

.pwa-theme .primary-btn {
    background-color: #3b82f6;
    /* Ensure vibrant blue button */
    border-radius: 8px;
    font-weight: 600;
}

.pwa-theme .branding h1 {
    color: #0f172a;
}

/* App container adjustments for PWA mode */
.pwa-theme .app-container {
    background: rgba(255, 255, 255, 0.95);
    /* Slight translucent container for main app */
    margin: 10px;
    border-radius: 16px;
    height: calc(100vh - 20px);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .pwa-theme .app-container {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        background: #f8fafc;
        /* Revert to solid on mobile inner view for performance/look */
    }
}

/* Worker Status Panel */
.status-panel {
    background-color: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

.status-panel h4 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.worker-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: transform 0.1s;
}

.worker-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.worker-info {
    display: flex;
    flex-direction: column;
}

.worker-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.worker-state {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 4px;
}

/* Status Colors */
.state-working {
    color: var(--success);
}

.state-paused {
    color: var(--warning);
}

.state-out {
    color: var(--text-muted);
}

.state-vacation {
    color: #8b5cf6;
}

/* Purple */
.state-sick {
    color: var(--danger);
}

/* Reports Layout */
.reports-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.reports-container .report-controls.card {
    width: 100%;
    max-width: 600px;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.control-group label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.control-group select,
.control-group input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background-color: white;
}

/* Report Actions Box (Restored Centered Layout) */
.report-controls {
    display: flex;
    flex-direction: column;
    /* Force vertical stacking */
    gap: 10px;
    align-items: center;
    width: 100%;
}

.report-actions-box {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    width: 100%;
    align-items: center;
}

.report-actions-box button {
    width: auto;
    min-width: 150px;
    padding: 12px 24px;
    justify-content: center;
}

@media (max-width: 768px) {
    .report-actions-box {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .report-actions-box button {
        width: 100%;
        max-width: 300px;
        /* Limit width on mobile */
    }
}