/* ═══════════════════════════════════════════════════════════════
   DESKTOP UI - PROFESSIONAL SOP GENERATOR
   Full styles for desktop interface
   ═══════════════════════════════════════════════════════════ */

/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --accent-color: #f5576c;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #2d3748;
    --text-medium: #4a5568;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* ============ MAIN CONTAINER ============ */
.app-container {
    max-width: 1800px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

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

/* ============ HEADER ============ */
.app-header {
    background: var(--primary-gradient);
    color: white;
    padding: 32px 40px;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="rgba(255,255,255,0.1)" d="M0,96L48,112C96,128,192,160,288,160C384,160,480,128,576,122.7C672,117,768,139,864,144C960,149,1056,139,1152,122.7C1248,107,1344,85,1392,74.7L1440,64L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path></svg>');
    opacity: 0.3;
}

.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
}

.header-left p {
    font-size: 16px;
    opacity: 0.95;
    font-weight: 400;
}

.header-right {
    text-align: right;
}

.version-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    margin-bottom: 8px;
}

.credit-link {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: var(--transition);
    display: block;
}

.credit-link:hover {
    color: white;
    transform: translateX(-4px);
}

/* ============ MAIN LAYOUT ============ */
.main-layout {
    display: grid;
    grid-template-columns: 440px 1fr;
    height: calc(100vh - 200px);
    min-height: 600px;
}

/* ============ CONTROL PANEL (SIDEBAR) ============ */
.controls-panel {
    background: var(--bg-light);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 28px;
    max-height: 100%;
}

.controls-panel::-webkit-scrollbar {
    width: 10px;
}

.controls-panel::-webkit-scrollbar-track {
    background: transparent;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea, #764ba2);
    border-radius: 10px;
}

.controls-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5568d3, #6a3f8f);
}

.control-section {
    background: white;
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.control-section:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 3px solid transparent;
    background: linear-gradient(to right, var(--primary-color), transparent) bottom / 100% 3px no-repeat;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    width: 6px;
    height: 24px;
    background: var(--primary-gradient);
    border-radius: 3px;
    box-shadow: 0 0 12px rgba(102, 126, 234, 0.4);
}

.section-icon {
    font-size: 20px;
}

/* ============ FORM ELEMENTS ============ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-medium);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-dark);
    background: white;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

input:hover,
select:hover,
textarea:hover {
    border-color: #cbd5e0;
}

select {
    cursor: pointer;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%23667eea" d="M6 9L1 4h10z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    appearance: none;
}

textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.6;
}

/* ============ CHECKBOX GRID ============ */
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.checkbox-item:hover {
    background: #e6f0ff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-item label {
    margin: 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

/* ============ COLLAPSIBLE SECTIONS ============ */
.collapsible-section {
    margin-bottom: 14px;
}

.collapsible-header {
    background: var(--bg-light);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    border: 2px solid transparent;
}

.collapsible-header:hover {
    background: #e6f0ff;
    border-color: var(--primary-color);
}

.collapsible-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.collapsible-icon {
    transition: transform 0.3s;
    color: var(--primary-color);
    font-weight: bold;
}

.collapsible-header:hover .collapsible-icon {
    transform: scale(1.2);
}

.collapsible-content {
    padding: 18px;
    border: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: white;
    display: none;
}

/* ============ PREVIEW PANEL ============ */
.preview-panel {
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.preview-toolbar {
    background: white;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.preview-toolbar h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-buttons {
    display: flex;
    gap: 12px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

#preview-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
    background: #ffffff;
}

#preview {
    width: 210mm;
    background: white;
    padding: 20mm;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============ STATUS BAR ============ */
.status-bar {
    background: white;
    padding: 16px 32px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-light);
}

.status-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.credit-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.credit-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.credit-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ============ SUBSECTIONS ============ */
.subsection-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 20px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1600px) {
    .main-layout {
        grid-template-columns: 400px 1fr;
    }
}

@media (max-width: 1400px) {
    .main-layout {
        grid-template-columns: 360px 1fr;
    }
    .controls-panel {
        padding: 20px;
    }
}

@media (max-width: 1200px) {
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
}

/* ============ PRINT STYLES ============ */
@media print {
    body {
        visibility: hidden !important;
    }

    #preview, #preview * {
        visibility: visible !important;
    }

    #preview {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        min-height: 297mm !important;
        margin: 0 !important;
        padding: 20mm !important;
        background: white !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    @page {
        size: A4;
        margin: 0;
    }
}
/* =====================================================
   PDF EXPORT – HARD RESET FOR html2canvas
   (Desktop overlay & blur fix)
   ===================================================== */
body.pdf-export *,
body.pdf-export *::before,
body.pdf-export *::after {
  backdrop-filter: none !important;
  filter: none !important;
  opacity: 1 !important;
  box-shadow: none !important;
}

body.pdf-export #preview-wrapper {
  background: #ffffff !important;
}

body.pdf-export #preview {
  background: #ffffff !important;
}
/* =====================================================
   PDF PAGE BREAK CONTROL – SAFE & WORD-LIKE
   ===================================================== */

/* Never split headings from their content */
#preview h2,
#preview h3 {
  page-break-after: avoid !important;
  break-after: avoid-page !important;
}

/* Never split tables */
#preview table {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Never split lists */
#preview ol,
#preview ul {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Avoid splitting list items */
#preview li {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Avoid splitting approval/signature block */
#preview .approvals,
#preview .signature-table {
  page-break-inside: avoid !important;
}
