:root {
    --primary: #6A0DAD;
    /* Purple */
    --secondary: #28A745;
    /* Green */
    --accent: #5e17eb;
    --dark: #1a1a2e;
    --light: #f4f7f6;
    --white: #ffffff;
    --text: #2d3436;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Modales */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow);
}

body {
    background: var(--white);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.login-form-box {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow);
    display: none;
    margin-top: 1rem;
}

.login-form-box.active {
    display: block !important;
    animation: slideUp 0.4s ease;
}

.admin-access-btn {
    margin-top: 2rem;
    background: var(--dark);
    color: var(--white);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.screen {
    display: none !important;
    min-height: 100vh;
    width: 100%;
}

.screen.active {
    display: flex !important;
}

#login-screen {
    justify-content: center;
    align-items: center;
    background: var(--white);
    flex-direction: column;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
    animation: slideUp 0.8s ease;
}

.login-logo {
    width: 180px;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.slogan {
    color: var(--secondary);
    font-style: italic;
    margin-bottom: 2rem;
    font-weight: 500;
}

.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.user-card {
    border: 2px solid #eee;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    background: #fdfdfd;
}

.user-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary);
    background: #f8fff9;
}

.user-card.selected {
    border-color: var(--primary);
    background: #f9f5ff;
    box-shadow: 0 5px 15px rgba(106, 13, 173, 0.1);
}

.user-avatar {
    font-size: 2.5rem;
    color: #ccc;
    margin-bottom: 10px;
    transition: color 0.3s;
}

.user-card.selected .user-avatar {
    color: var(--primary);
}

.user-card:hover .user-avatar {
    color: var(--secondary);
}

.user-info-card {
    display: flex;
    flex-direction: column;
}

.user-name-small {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.user-role-small {
    font-size: 0.75rem;
    color: #777;
}

.form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s, background 0.3s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    width: 100%;
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-primary:hover {
    background: #550a8a;
    transform: translateY(-2px);
}

/* Sidebar */
/* Main View definition moved to structure section */

.sidebar {
    width: 250px;
    background: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 2rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-links {
    list-style: none;
    padding: 1rem 0;
}

.nav-links li {
    padding: 1rem 2rem;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links li:hover,
.nav-links li.active {
    background: rgba(255, 255, 255, 0.1);
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 1rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: var(--shadow);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 1rem;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background: #f4f4f4;
    color: #666;
    font-size: 0.9rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--primary);
    margin-right: 10px;
}

.text-danger {
    color: #dc3545;
}

.view-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--primary);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

/* Report FO-MTT-001 */
.report-form-container {
    background: white;
    padding: 2rem;
    border: 1px solid #ddd;
    max-width: 900px;
    margin: 0 auto;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--text-dark);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.header-center {
    text-align: center;
}

.header-center h1 {
    font-size: 1.2rem;
    color: var(--primary);
}

.slogan-small {
    font-size: 0.7rem;
    color: var(--secondary);
    margin-top: -5px;
}

.header-meta {
    font-size: 0.8rem;
    text-align: right;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h3 {
    background: #f0f0f0;
    padding: 8px 15px;
    font-size: 1rem;
    border-left: 4px solid var(--secondary);
    margin-bottom: 1rem;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
}

.field label {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.details-box {
    background: #f9f9f9;
    padding: 10px;
    border: 1px dashed #ccc;
    font-size: 0.85rem;
    columns: 2;
    margin-top: 10px;
}

/* Signature Pads */
.sig-pad {
    border: 1px solid #ccc;
    background: #fff;
    width: 100%;
    height: 120px;
    cursor: crosshair;
    touch-action: none;
}

.btn-clear {
    background: #eee;
    border: 1px solid #ccc;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    margin-top: 5px;
    width: fit-content;
}

.photo-placeholder {
    border: 2px dashed #ddd;
    padding: 20px;
    text-align: center;
    color: #999;
}

.actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Calendar */
.calendar-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 0 auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.day-head {
    font-weight: bold;
    text-align: center;
    color: #999;
    padding: 10px;
}

.day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
    font-size: 0.9rem;
    position: relative;
}

.day.today {
    background: var(--bg-light);
    border: 2px solid var(--primary);
    font-weight: bold;
}

.day.mtt-scheduled {
    background: rgba(40, 167, 69, 0.1);
}

.mtt-dot {
    width: 6px;
    height: 6px;
    background: var(--secondary);
    border-radius: 50%;
    position: absolute;
    bottom: 5px;
}

@media print {
    .no-print {
        display: none !important;
    }
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Main Layout Structure */
#app {
    width: 100%;
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--white);
    border-right: 1px solid #edf2f7;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
    z-index: 100;
}

.sidebar-header {
    padding: 2rem;
}

.sidebar-logo {
    width: 160px;
    height: auto;
}

.menu-label {
    padding: 0 2rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: #a0aec0;
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    padding: 1rem 2rem;
    color: #4a5568;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    border-right: 4px solid transparent;
}

.nav-links li:hover {
    background: #f7fafc;
    color: var(--primary);
}

.nav-links li.active {
    background: #f8f0ff;
    color: var(--primary);
    border-right: 4px solid var(--primary);
}

.sidebar-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #edf2f7;
    color: #cbd5e0;
    font-size: 0.75rem;
}

.content-area {
    flex: 1;
    min-height: 100vh;
    background: var(--light);
}

.main-header {
    height: 70px;
    background: var(--white);
    border-bottom: 1px solid #edf2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar-small {
    width: 35px;
    height: 35px;
    background: #f8f0ff;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

/* Professional Report Structure */
.report-paper {
    background: white;
    padding: 2cm;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    color: #1a202c;
    font-size: 11pt;
    line-height: 1.4;
}

.report-header {
    display: grid;
    grid-template-columns: 220px 1fr max-content;
    /* Exact sizes for edges, max-content dynamically fits the non-wrapping text */
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.header-logo {
    display: flex;
    justify-content: flex-start;
}

.header-logo img {
    width: 220px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.header-center {
    text-align: center;
    /* allow the title to wrap if absolutely necessary, but keep it in its cell */
}

.header-center h1 {
    font-size: 1.3rem;
    margin: 0;
    line-height: 1.2;
}

.header-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    font-size: 9pt;
    text-align: right;
    white-space: nowrap !important;
    /* Force no wrap */
}

.header-meta p {
    margin: 2px 0;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    table-layout: fixed;
}

.report-table th,
.report-table td {
    border: 1px solid #2d3748;
    padding: 8px 12px;
    vertical-align: top;
    text-align: left;
}

.report-table th {
    background-color: #f7fafc;
    font-size: 9pt;
    text-transform: uppercase;
    color: #4a5568;
    width: 30%;
}

.report-section-header {
    background-color: var(--primary) !important;
    color: white !important;
    padding: 8px 15px;
    font-weight: bold;
    text-transform: uppercase;
    margin-top: 25px;
    margin-bottom: 0;
    border: 1px solid #2d3748;
    border-bottom: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.report-block {
    border: 1px solid #2d3748;
    padding: 15px;
    margin-bottom: 20px;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    border: 1px solid #2d3748;
}

.report-grid>div {
    padding: 10px;
    border: 0.5px solid #2d3748;
    display: flex;
    flex-direction: column;
}

.report-grid label {
    display: block;
    font-size: 8pt;
    font-weight: bold;
    color: #718096;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.report-text-box {
    min-height: 80px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 10pt;
}

.report-paper textarea {
    font-family: inherit;
    font-size: 10pt;
    color: #1a202c;
    line-height: 1.5;
    padding: 5px;
    width: 100%;
    border: none;
    background: transparent;
    overflow: hidden;
    resize: none;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.report-paper textarea::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Webkit */
}

.print-mirror {
    display: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 10pt;
    line-height: 1.5;
    padding: 5px;
    color: #1a202c;
    min-height: 20px;
}

.report-paper input[type="text"],
.report-paper input[type="date"],
.report-paper input[type="time"],
.report-paper select {
    border: 1px solid #e2e8f0;
    padding: 4px;
    border-radius: 4px;
    font-size: 10pt;
    width: 100%;
}



.sig-pad {
    width: 100%;
    height: 120px;
    background: #f8fafc;
    border: 1px dashed #cbd5e0;
    border-radius: 8px;
    margin-top: 5px;
    touch-action: none;
}

.btn-logout {
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    font-size: 1.2rem;
    margin-left: 1rem;
}

.btn-logout:hover {
    color: var(--primary);
}

/* Dashboard Cards */
.view-container {
    padding: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: #718096;
    font-size: 0.85rem;
    font-weight: 700;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stat-icon.blue {
    background: #ebf4ff;
    color: #4299e1;
}

.stat-icon.green {
    background: #f0fff4;
    color: #48bb78;
}

.stat-icon.orange {
    background: #fffaf0;
    color: #ed8936;
}

.stat-icon.purple {
    background: #f8f0ff;
    color: #9f7aea;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
}

/* Dashbord Charts & Full Cards */
.full-card {
    background: var(--white);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--dark);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        width: 260px;
        height: 100vh;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
        z-index: 2000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content-area {
        margin-left: 0;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .main-header {
        padding: 0 1rem;
    }

    .sidebar-logo {
        width: 120px;
    }

    .stat-card {
        padding: 1.2rem;
    }

    #main-view {
        flex-direction: column;
        display: block;
        /* Remove flex constraints in mobile to allow normal flow */
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Allow the report container to scroll horizontally if the PC layout is too wide */
    .report-form-container {
        overflow-x: auto;
        padding: 10px !important;
    }

    .report-paper {
        min-width: 800px;
        /* Ensure it keeps a desktop-like width even on mobile */
        margin: 0 auto;
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        margin: 0 !important;
    }

    .no-print,
    .actions,
    .btn-clear,
    .nav-links,
    .sidebar,
    .main-header,
    .sidebar-footer {
        display: none !important;
    }

    .content-area {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    .report-form-container {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .report-paper {
        padding: 0 !important;
        border: none !important;
        min-width: initial !important;
        /* Fix for mobile PDF clipping */
        width: 100% !important;
        margin: 0 !important;
    }

    .report-section-header {
        background-color: #6A0DAD !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-table th,
    .report-table td,
    .report-block,
    .report-grid {
        border: 1px solid #000 !important;
    }

    .report-paper textarea {
        display: none !important;
    }

    .print-mirror {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
    }

    .sig-pad {
        border: 1px solid #000 !important;
        height: 80px !important;
    }

    .header-center h1 {
        font-size: 1.1rem !important;
        /* Force smaller size on print so it fits in 1fr */
    }

    @page {
        margin: 0.8cm;
    }
}