/* Base & Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f1f5f9;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

/* =========================================
   LOGIN VIEW
========================================= */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4ebf5 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(43, 108, 176, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
    top: -200px;
    right: -200px;
    border-radius: 50%;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 3.5rem 3rem;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08), 0 5px 15px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 420px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.login-logo {
    max-width: 250px;
    margin-bottom: 2rem;
    height: auto;
}

.login-box h2 {
    margin-bottom: 2rem;
    color: #1a365d;
    font-size: 1.5rem;
    font-weight: 600;
}

.login-box .form-group {
    margin-bottom: 1.2rem;
}

.login-box .form-group input {
    width: 100%;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.login-box .form-group input:focus {
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(43, 108, 176, 0.1);
    outline: none;
    border-color: #3182ce;
}

/* Base Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

.primary-btn {
    background: linear-gradient(135deg, #2b6cb0 0%, #2c5282 100%);
    color: white;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(43, 108, 176, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(43, 108, 176, 0.4);
}

.secondary-btn {
    background: #e2e8f0;
    color: #4a5568;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 6px;
}

.secondary-btn:hover {
    background: #cbd5e0;
}

/* =========================================
   DASHBOARD LAYOUT
========================================= */
.view-hidden {
    display: none !important;
}

/* When dashboard is active, it must be flex row */
#dashboard-layout.view-active {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.sidebar-header {
    padding: 2.5rem 2rem;
    background: #0f172a;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
    max-width: 180px;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.sidebar-nav {
    list-style: none;
    padding: 1.5rem 0;
    flex: 1;
}

.sidebar-nav li {
    padding: 1rem 2rem;
    margin: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    color: #94a3b8;
}

.nav-icon {
    margin-right: 12px;
    font-size: 1.2rem;
    opacity: 0.7;
}

.sidebar-nav li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.sidebar-nav li.active {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-nav li.active .nav-icon {
    opacity: 1;
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 2.5rem 3rem;
    overflow-y: auto;
    height: 100vh;
    background: #f1f5f9;
}

.section-header-dash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.section-header-dash h2 {
    color: #0f172a;
    font-size: 1.8rem;
    font-weight: 700;
}

.dash-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.dash-section.active-section {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   ADMIN TABLES
========================================= */
.admin-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02), 0 10px 15px rgba(0, 0, 0, 0.03);
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table th,
.admin-table td {
    padding: 1.25rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.admin-table th {
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}

.admin-table tbody tr {
    transition: background-color 0.2s ease;
}

.admin-table tbody tr:hover {
    background-color: #f8fafc;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.btn-regenerate-global,
.btn-view-history {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* =========================================
   FORM BUILDER (Inside Dashboard)
========================================= */
.form-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02), 0 10px 15px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.form-header {
    background: #0f172a;
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-header h2 {
    font-weight: 600;
    font-size: 1.2rem;
}

.styled-form {
    padding: 2rem;
}

.form-section {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #edf2f7;
}

.form-section h3 {
    font-size: 1.2rem;
    color: #2d3748;
    margin-bottom: 1.2rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
    outline: none;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.file-uploads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.file-drop-area {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    position: relative;
    cursor: pointer;
    background: #f7fafc;
    transition: all 0.2s;
}

.file-drop-area:hover {
    border-color: #3182ce;
    background: #ebf8ff;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-message {
    color: #718096;
    font-weight: 500;
}

.image-preview {
    margin-top: 1rem;
    max-width: 100%;
    max-height: 120px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-actions {
    text-align: right;
    margin-top: 2rem;
}

/* =========================================
   MODALS
========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: floatUp 0.3s ease-out forwards;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: #0f172a;
}

.modal-content select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: #a0aec0;
    font-size: 0.9rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e2e8f0;
}

.divider span {
    padding: 0 10px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* =========================================
   PDF TEMPLATE STYLES (HIDDEN)
========================================= */
#pdf-wrapper {
    display: none;
}

#pdf-template {
    width: 794px;
    padding: 25px 30px;
    background: white;
    font-family: 'Times New Roman', Times, serif;
    color: #000;
    font-size: 11px;
    position: relative;
    z-index: 1;
}

.watermark-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png'),
        url('background.png');
    background-repeat: no-repeat;
    /* A4 page height at 794px width is ~1123px. 
       Page centers at 561px, 1684px, 2807px, 3930px, etc.
       Offsetting by approx half the image height (175px) to perfectly center it: */
    background-position: 
        center 386px,
        center 1509px,
        center 2632px,
        center 3755px,
        center 4878px,
        center 6001px,
        center 7124px,
        center 8247px,
        center 9370px,
        center 10493px;
    background-size: 350px auto;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
}

.pdf-header,
.pdf-title-section,
.pdf-tc-date,
.pdf-table,
.pdf-footer {
    position: relative;
    z-index: 1;
}

.pdf-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
}

.pdf-logo-img {
    margin-right: 8px;
}

.pdf-header-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding-top: 2px;
    margin-right: -30px;
}

.bar-blue {
    height: 14px;
    background-color: #0056b3;
    width: 100%;
}

.bar-gray {
    height: 6px;
    background-color: #cccccc;
    width: 100%;
}

.pdf-title-section {
    text-align: center;
    margin: 5px 0;
    line-height: 1.3;
    font-weight: bold;
}

.form-title {
    font-size: 13px;
}

.sub-title {
    font-size: 12px;
}

.underline {
    text-decoration: underline;
}

.pdf-tc-date {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 5px;
}

.pdf-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-top: 1px solid #000;
    border-left: 1px solid #000;
    margin-bottom: 15px;
}

.pdf-table th,
.pdf-table td {
    border-bottom: 1px solid #000;
    border-right: 1px solid #000;
    border-top: none;
    border-left: none;
    padding: 3px 6px;
    vertical-align: top;
    line-height: 1.25;
}

.col-num {
    width: 25px;
    text-align: center;
}

.col-ques {
    width: 45%;
}

.col-colon {
    width: 20px;
    text-align: center;
}

.col-ans {
    font-family: Arial, sans-serif;
}

.pdf-footer {
    font-size: 11px;
    line-height: 1.4;
}

.certify-text {
    text-align: justify;
    margin-bottom: 10px;
}

.signatures {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
    height: 90px;
}

.stamp-container,
.sign-container {
    width: 200px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stamp-container img,
.sign-container img {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
}

.disclaimer {
    font-size: 10px;
    text-align: justify;
    margin-top: 10px;
}


/* =========================================
   MOBILE RESPONSIVENESS
========================================= */
@media (max-width: 768px) {

    /* Login */
    .login-box {
        padding: 2rem 1.5rem;
        margin: 1rem;
    }

    /* Dashboard Layout */
    #dashboard-layout.view-active {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar-header {
        padding: 1.5rem 1rem;
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 0.5rem;
        justify-content: center;
    }

    .sidebar-nav li {
        padding: 0.5rem 1rem;
        margin: 0.2rem;
        font-size: 0.9rem;
    }

    .nav-icon {
        margin-right: 6px;
    }

    .main-content {
        padding: 1.5rem 1rem;
        height: auto;
        overflow-y: visible;
    }

    /* Typography & Headers */
    .section-header-dash {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .section-header-dash h2 {
        font-size: 1.4rem;
    }

    /* Forms & Grids */
    .row-2,
    .file-uploads {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .styled-form {
        padding: 1.5rem 1rem;
    }

    /* Tables */
    .admin-content {
        padding: 1rem;
        overflow-x: auto;
        /* Enable horizontal scroll for tables */
    }

    .admin-table th,
    .admin-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Modals */
    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }
}

/* =========================================
   DROPDOWN BUTTON STYLES
========================================= */
.dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: white;
    min-width: 260px;
    box-shadow: 0px 8px 24px rgba(0,0,0,0.15);
    z-index: 100;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid #e2e8f0;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f1f5f9;
    color: #2b6cb0;
}