/* ==========================================================================
   SBM Toilet Construction Notice Generator - Stylesheet
   Author: myprinttool.in
   ========================================================================== */

:root {
    --primary-color: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #f0fdfa;
    --secondary-color: #1e3a8a;
    --secondary-hover: #172554;
    --accent-color: #ea580c;
    --accent-hover: #c2410c;
    --text-main: #0f172a;
    --text-muted: #475569;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #cbd5e1;
    --border-hover: #94a3b8;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Mukta', 'Noto Sans Devanagari', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100vh;
}

/* ================= Topbar ================= */
.topbar {
    background: linear-gradient(135deg, #134e4a 0%, #0f766e 100%);
    color: #ffffff;
    padding: 10px 20px;
    box-shadow: 0 4px 20px rgba(15, 118, 110, 0.25);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.topbar-wrapper {
    max-width: 1250px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.back-btn {
    color: #ffffff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.topbar-logo-title {
    font-size: 1.25rem;
    font-weight: 850;
    letter-spacing: -0.02em;
    color: #99f6e4;
    display: flex;
    align-items: center;
}

.topbar-center {
    flex: 1;
    text-align: center;
    min-width: 280px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 9999px;
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.balance-badge {
    background: #042f2e;
    color: #5eead4;
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 12.5px;
    font-weight: 800;
    border: 1px solid #115e59;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ================= Toolbar ================= */
.toolbar {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--primary-light);
    color: var(--primary-hover);
    border-color: #99f6e4;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.12);
}

/* Common Buttons */
.btn-primary {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
    transition: all 0.2s;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
    transition: all 0.2s;
}

.btn-success:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    transform: translateY(-1px);
}

.btn-warning {
    background: #f8fafc;
    color: #334155;
    border: 1.5px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-warning:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.btn-danger {
    background: #ef4444;
    color: #ffffff;
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ================= Content Tabs ================= */
.content-area {
    display: none;
}

.content-area.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= Form & Editor Layout ================= */
.editor-section {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 13px;
    font-weight: 750;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-main);
    background: #f8fafc;
    transition: all 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Preset Pills */
.preset-pill {
    padding: 7px 15px;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    border: 1.5px solid #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-pill:hover {
    background: #e2e8f0;
    color: #0f766e;
    border-color: #99f6e4;
    transform: translateY(-1px);
}

.preset-pill.active {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: #ffffff;
    border-color: #0d9488;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

/* ================= Tables ================= */
.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #ffffff;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.custom-table th,
.custom-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.custom-table th {
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 800;
    font-size: 12.5px;
}

.custom-table tr:hover {
    background: #f8fafc;
}

/* ================= Dynamic Signatures in Settings ================= */
.sig-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.sig-item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    padding: 10px 14px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sig-item-row:hover {
    border-color: #99f6e4;
    background: #f0fdfa;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.08);
}

.sig-num-badge {
    width: 28px;
    height: 28px;
    background: #ccfbf1;
    color: #0f766e;
    font-weight: 800;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    border: 1px solid #99f6e4;
}

.sig-title-input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    background: #ffffff;
    transition: all 0.2s;
    outline: none;
}

.sig-title-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.sig-btn-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.sig-action-btn {
    padding: 7px 10px;
    border-radius: 7px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sig-action-btn:hover:not(:disabled) {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #94a3b8;
}

.sig-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sig-delete-btn {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
}

.sig-delete-btn:hover:not(:disabled) {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}

/* ================= PRINT PREVIEW & A4 SHEET STYLES ================= */
#printContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 20px 0;
}

.notice-page {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    padding: 14mm 16mm 10mm 16mm;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'Mukta', 'Noto Sans Devanagari', serif;
    color: #000000;
    overflow: hidden;
}

/* 2 Notices per page (Compact Mode) */
.notice-page.compact-page {
    padding: 10mm 14mm;
    height: auto;
    min-height: 297mm;
}

.notice-box-half {
    border: 1.5px solid #334155;
    padding: 8mm 10mm;
    border-radius: 6px;
    height: 135mm;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.notice-divider {
    border-top: 1.5px dashed #64748b;
    margin: 8mm 0;
    position: relative;
    text-align: center;
}

.notice-divider::after {
    content: "✂️ यहाँ से काटकर अलग करें (Cut Here)";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    padding: 0 10px;
    font-size: 10.5px;
    color: #64748b;
    font-weight: 700;
}

/* Notice Header */
.notice-header {
    text-align: center;
    border-bottom: 2px solid #000000;
    padding-bottom: 8px;
    margin-bottom: 12px;
    position: relative;
    z-index: 2;
}

.notice-header-title {
    font-size: 19.5px;
    font-weight: 800;
    color: #000000;
    line-height: 1.3;
    letter-spacing: normal !important;
    white-space: nowrap;
    word-break: keep-all;
    font-family: 'Noto Sans Devanagari', 'Mukta', sans-serif !important;
    overflow: visible;
}

.notice-header-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin-top: 2px;
    letter-spacing: normal !important;
    white-space: nowrap;
    word-break: keep-all;
    font-family: 'Noto Sans Devanagari', 'Mukta', sans-serif !important;
}

.notice-header-scheme {
    font-size: 12.5px;
    font-weight: 700;
    color: #0f766e;
    display: inline-block;
    background: #f0fdfa;
    padding: 2px 12px;
    border-radius: 4px;
    border: 1px solid #99f6e4;
    margin-top: 4px;
    letter-spacing: normal !important;
    white-space: nowrap;
    word-break: keep-all;
    font-family: 'Noto Sans Devanagari', 'Mukta', sans-serif !important;
}

/* Notice Meta Bar (Ref & Date) */
.notice-meta-bar {
    display: flex;
    justify-content: space-between;
    font-size: 14.5px;
    font-weight: 750;
    margin-bottom: 14px;
    border-bottom: 1px dashed #94a3b8;
    padding-bottom: 6px;
    position: relative;
    z-index: 2;
}

/* Recipient Block */
.notice-to-block {
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    z-index: 2;
}

.notice-to-block .label-to {
    font-weight: 850;
    text-decoration: underline;
    display: block;
    margin-bottom: 2px;
}

.notice-to-block .recipient-info {
    font-weight: 700;
    padding-left: 15px;
}

/* Subject Block */
.notice-subject {
    font-size: 15px;
    font-weight: 850;
    background: #f8fafc;
    border-left: 4px solid #000000;
    padding: 7px 12px;
    margin-bottom: 14px;
    line-height: 1.45;
    position: relative;
    z-index: 2;
}

/* Body Text */
.notice-body {
    font-size: 15px;
    line-height: 1.7;
    text-align: justify;
    margin-bottom: 14px;
    position: relative;
    z-index: 2;
}

.notice-body p {
    margin: 0 0 8px 0;
    line-height: 1.7;
    text-indent: 0;
}

.highlight-val {
    font-weight: 850;
    color: #000000;
    text-decoration: underline;
}

/* Warning Badge Inside Notice */
.notice-warning-text {
    font-weight: 800;
    border: 1.5px solid #000000;
    padding: 7px 14px;
    border-radius: 4px;
    background: #fffbeb;
    margin: 10px 0;
    font-size: 14px;
}

/* Signatures */
.notice-signatures {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 20px;
    gap: 15px;
    position: relative;
    z-index: 2;
}

.notice-sig-box {
    text-align: center;
    flex: 1;
}

.notice-sig-line {
    border-top: 1px dotted #000000;
    width: 80%;
    margin: 0 auto 4px auto;
}

.notice-sig-title {
    font-size: 14px;
    font-weight: 800;
}

/* Tear-Off Acknowledgment Slip (पावती रसीद) */
.notice-receipt-slip {
    border-top: 2px dashed #000000;
    padding-top: 12px;
    margin-top: 26px;
    position: relative;
    z-index: 2;
    background: #fafaf9;
    padding: 12px 16px;
    border: 1.5px dashed #44403c;
    border-radius: 6px;
}

.receipt-slip-title {
    text-align: center;
    font-size: 14.5px;
    font-weight: 900;
    margin-bottom: 6px;
    text-decoration: underline;
}

.receipt-slip-body {
    font-size: 13px;
    line-height: 1.65;
}

.receipt-slip-signs {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    font-size: 13px;
    font-weight: 750;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-card {
    background: #ffffff;
    padding: 30px 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    max-width: 420px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #ccfbf1;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================= Print Page & Media Queries ================= */
@page {
    size: A4 portrait;
    margin: 8mm 10mm 8mm 10mm;
}

@media print {
    html, body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .topbar,
    .toolbar,
    #editor-tab,
    #database-tab,
    #settings-tab,
    .support-banner,
    .faq-section,
    footer,
    .loading-overlay,
    #alerts-container,
    .print-hide {
        display: none !important;
    }

    #print-tab {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    #printContainer {
        padding: 0 !important;
        margin: 0 !important;
        gap: 0 !important;
        display: block !important;
        width: 100% !important;
    }

    .notice-page {
        width: 100% !important;
        height: 100% !important;
        min-height: 270mm !important;
        max-height: 282mm !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 auto !important;
        padding: 4mm 8mm 4mm 8mm !important;
        page-break-after: always !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        box-sizing: border-box !important;
    }
}
