/* ==========================================================
   Al-Marsid Financial Services - Customer Notice Poster CSS
   ========================================================== */

:root {
    --brand-teal-dark: #0f5b63;
    --brand-teal-primary: #1d7a82;
    --brand-teal-light: #269ba7;
    --brand-teal-soft: #e0f2fe;
    --brand-slate: #334155;
    --brand-slate-light: #64748b;
    --brand-gold: #d97706;
    
    --bg-poster: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #cbd5e1;
    
    --font-heading: 'Cairo', sans-serif;
    --font-body: 'Tajawal', sans-serif;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #0b1329;
    color: #f8fafc;
    font-family: var(--font-body);
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum" 1, "tnum" 1;
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* App Header */
.app-header {
    background: #152238;
    border-bottom: 2px solid var(--brand-teal-primary);
    padding: 12px 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--brand-teal-primary), var(--brand-teal-dark));
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(29, 122, 130, 0.4);
}

.app-logo h1 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
}

.sub-logo {
    font-size: 0.78rem;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-teal-primary), var(--brand-teal-dark));
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(29, 122, 130, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(29, 122, 130, 0.6);
}

.btn-secondary {
    background: #334155;
    color: #f8fafc;
    border: 1px solid #475569;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--brand-teal-primary);
    color: #38bdf8;
}

.btn-outline:hover {
    background: rgba(56, 189, 248, 0.1);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

/* Workspace Grid */
.app-workspace {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    padding: 20px;
    flex: 1;
}

/* Sidebar Controls */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-card {
    background: #152238;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 10px;
}

.step-num {
    background: var(--brand-teal-primary);
    color: #ffffff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 0.85rem;
    font-family: var(--font-heading);
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--brand-teal-primary);
    background: rgba(29, 122, 130, 0.05);
    border-radius: 10px;
    padding: 22px 15px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.dragover {
    background: rgba(29, 122, 130, 0.15);
    border-color: #38bdf8;
}

.drop-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 4px;
}

.upload-text {
    font-size: 0.88rem;
    color: #cbd5e1;
}

.upload-hint {
    font-size: 0.75rem;
    color: #64748b;
    display: block;
    margin-top: 4px;
}

.file-info-badge {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #34d399;
    padding: 10px 14px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.remove-file {
    cursor: pointer;
    padding: 2px 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.remove-file:hover {
    background: #ef4444;
    color: #fff;
}

.hidden {
    display: none !important;
}

/* Forms */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 5px;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="date"],
.form-group textarea {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    color: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    outline: none;
    transition: border 0.2s;
}

.form-group textarea {
    resize: vertical;
    line-height: 1.5;
}

#reportDateInput,
.form-group input[type="date"] {
    direction: ltr !important;
    text-align: right !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-variant-numeric: lining-nums tabular-nums !important;
    font-feature-settings: "lnum" 1, "tnum" 1 !important;
}

.meta-row,
#posterDate,
.phone-tag,
.amount-cell,
.seq {
    font-variant-numeric: lining-nums tabular-nums !important;
    font-feature-settings: "lnum" 1, "tnum" 1 !important;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--brand-teal-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Presets Box */
.presets-box {
    margin-top: 8px;
    background: #0f172a;
    border: 1px solid #1e293b;
    padding: 10px;
    border-radius: 8px;
}

.preset-title {
    display: block;
    font-size: 0.78rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.preset-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-preset {
    background: #1e293b;
    color: #38bdf8;
    border: 1px solid #334155;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.78rem;
    text-align: right;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-preset:hover {
    background: var(--brand-teal-dark);
    color: #ffffff;
    border-color: var(--brand-teal-primary);
}

/* Preview Panel */
.preview-panel {
    background: #152238;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #1e293b;
}

.preview-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    color: #38bdf8;
}

.records-count {
    background: #334155;
    color: #f8fafc;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
}

.poster-scroll-box {
    flex: 1;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 10px;
    background: #090f1d;
    border-radius: 8px;
}

/* ==========================================================
   Poster Canvas (Customer Facing)
   ========================================================== */
.poster-container {
    width: 794px;
    min-height: 1123px;
    background: var(--bg-poster);
    color: var(--text-primary);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    padding: 40px 45px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Formats */
.poster-container.format-square {
    width: 850px;
    min-height: 850px;
    padding: 35px;
}

.poster-container.format-story {
    width: 580px;
    min-height: 1030px;
    padding: 28px;
}

/* Top Accent Bar */
.poster-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
    background: var(--brand-teal-primary);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    z-index: 10;
}

/* Themes */
.poster-container.theme-teal::before {
    background: var(--brand-teal-primary);
}

.poster-container.theme-dark {
    background: #0f172a;
    color: #f8fafc;
}

.poster-container.theme-dark::before {
    background: #38bdf8;
}

.poster-container.theme-dark .notice-box {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

.poster-container.theme-dark table th {
    background: #1e293b;
    color: #38bdf8;
}

.poster-container.theme-dark table td {
    color: #cbd5e1;
}

.poster-container.theme-dark table tr:nth-child(even) {
    background: #1e293b;
}

.poster-container.theme-dark .phone-tag {
    background: #334155;
    color: #cbd5e1;
}

.poster-container.theme-clean::before {
    background: #334155;
}

/* Watermark */
.watermark-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-20deg);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(29, 122, 130, 0.03) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.poster-header {
    position: relative;
    z-index: 2;
    margin-bottom: 20px;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
}

.logo-box {
    width: 320px;
    max-width: 100%;
}

.official-logo-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.report-meta-box {
    text-align: left;
}

.badge-tag {
    display: inline-block;
    background: var(--brand-teal-soft);
    color: var(--brand-teal-dark);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 3px 12px;
    border-radius: 20px;
    margin-bottom: 5px;
}

.report-title {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.65rem;
    color: var(--brand-teal-dark);
    margin-bottom: 6px;
}

.meta-row {
    font-size: 0.88rem;
    color: var(--brand-slate-light);
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.slogan-bar {
    background: linear-gradient(90deg, var(--brand-teal-dark), var(--brand-teal-primary), var(--brand-teal-dark));
    color: #ffffff;
    text-align: center;
    padding: 8px 15px;
    border-radius: 6px;
    margin-top: 14px;
    box-shadow: 0 4px 10px rgba(15, 91, 99, 0.25);
}

.slogan-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: 0.5px;
}

/* Customer Notice Box */
.notice-box {
    position: relative;
    z-index: 2;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-right: 5px solid var(--brand-teal-primary);
    border-radius: 8px;
    padding: 18px 24px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.notice-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #cbd5e1;
}

.notice-header {
    display: inline-block;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1rem;
    color: var(--brand-teal-dark);
    margin-bottom: 0;
}

.notice-date-badge {
    font-size: 0.88rem;
    color: #475569;
    background: #e2e8f0;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-variant-numeric: lining-nums tabular-nums !important;
    font-feature-settings: "lnum" 1, "tnum" 1 !important;
}

.notice-content p {
    font-size: 0.96rem;
    line-height: 1.6;
    color: #334155;
    font-weight: 500;
}

/* Data Table */
.table-section {
    position: relative;
    z-index: 2;
    margin-bottom: 25px;
}

.poster-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
}

.poster-table th {
    background: var(--brand-teal-dark);
    color: #ffffff;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.98rem;
    padding: 13px 16px;
    text-align: right;
}

.poster-table td {
    padding: 11px 16px;
    font-size: 0.95rem;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
}

.poster-table tr:last-child td {
    border-bottom: none;
}

.poster-table tr:nth-child(even) {
    background: #f8fafc;
}

.seq {
    text-align: center;
    font-weight: 700;
    color: var(--brand-slate-light);
    font-family: var(--font-heading);
}

.name-cell {
    font-weight: 700;
    color: #0f172a;
}

.phone-cell {
    font-family: monospace;
    font-size: 0.92rem;
}

.phone-tag {
    background: #e2e8f0;
    padding: 3px 10px;
    border-radius: 4px;
    color: #334155;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.amount-cell {
    text-align: left;
    font-family: var(--font-heading);
    font-weight: 800;
    color: #0f172a;
    direction: ltr;
}

/* Footer Section */
.poster-footer {
    position: relative;
    z-index: 2;
    margin-top: 25px;
}

.footer-contact-bar {
    background: #1b2332;
    border-top: 3px solid var(--brand-teal-primary);
    color: #cbd5e1;
    padding: 16px 20px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 50px;
    line-height: 1;
}

/* Pagination Bar */
.pagination-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    padding: 12px 24px;
    border-radius: 10px;
    border: 1px solid #334155;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}

.btn-page {
    background: #0f5b63;
    color: #ffffff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-page:hover {
    background: #1d8a95;
    transform: translateY(-1px);
}

.page-info-text {
    font-size: 0.92rem;
    color: #e2e8f0;
    font-weight: 700;
    text-align: center;
    min-width: 200px;
}

/* ==========================================================
   Print CSS (Flawless PDF / Printer Isolation)
   ========================================================== */
@media print {
    /* Hide all elements on the page by default */
    body * {
        visibility: hidden !important;
    }

    /* Make ONLY #posterCard and its contents visible */
    #posterCard,
    #posterCard * {
        visibility: visible !important;
    }

    /* Force exact colors & backgrounds */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    @page {
        size: A4 portrait;
        margin: 0mm;
    }

    html, body {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        overflow: visible !important;
    }

    /* Absolute positioning at 0,0 to prevent layout offsets */
    #posterCard {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh !important;
        margin: 0 !important;
        padding: 40px 45px !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        transform: none !important;
        background: #ffffff !important;
    }

    .poster-container::before {
        border-radius: 0 !important;
    }

    .poster-table {
        width: 100% !important;
    }

    .poster-table tr {
        page-break-inside: avoid !important;
    }

    .poster-footer {
        margin-top: 30px !important;
        page-break-inside: avoid !important;
    }
}

/* ==========================================================
   Responsive & Mobile Experience CSS (Smartphones & Tablets)
   ========================================================== */

/* Tablet & Mobile Screens (<= 992px) */
@media (max-width: 992px) {
    .app-header {
        padding: 12px 16px;
    }

    .header-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .app-logo {
        justify-content: center;
        text-align: center;
    }

    .app-logo h1 {
        font-size: 1.1rem;
    }

    .sub-logo {
        font-size: 0.72rem;
    }

    .header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }

    .header-actions .btn {
        justify-content: center;
        padding: 10px 12px;
        font-size: 0.85rem;
        width: 100%;
    }

    .app-workspace {
        grid-template-columns: 1fr; /* Stack sidebar on top of preview */
        padding: 12px;
        gap: 16px;
    }

    .sidebar-panel {
        max-width: 100%;
    }

    .preview-panel {
        padding: 15px 10px;
    }

    /* Enable horizontal scrolling for poster on small screens */
    .poster-scroll-box {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
    }

    .poster-container {
        margin: 0 auto;
    }
}

/* Smartphone Screens (<= 576px) */
@media (max-width: 576px) {
    .app-header {
        padding: 10px 12px;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .header-actions {
        grid-template-columns: 1fr; /* Stack buttons vertically on small phones */
    }

    .panel-card {
        padding: 14px;
    }

    .poster-container {
        padding: 20px 15px;
    }

    .poster-header {
        padding-bottom: 12px;
        margin-bottom: 15px;
    }

    .official-logo-img {
        max-height: 55px;
    }

    .notice-box {
        padding: 14px 16px;
    }

    .poster-table th, 
    .poster-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .footer-contact-bar {
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
    }

    .footer-contact-bar div {
        justify-content: center;
    }

    .pagination-bar {
        padding: 10px 14px;
        gap: 10px;
        flex-direction: column;
    }

    .btn-page {
        width: 100%;
    }
}
