/* ============================================
   IWC Notification Package Generator
   Franmarine Underwater Services
   ============================================ */

/* CSS Variables */
:root {
    /* Franmarine Brand Colors */
    --primary: #0a3d62;
    --primary-dark: #062743;
    --primary-light: #1e5f8a;
    --accent: #e55039;
    --accent-hover: #c23616;
    
    /* Neutrals */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Typography */
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Consolas', 'Monaco', monospace;
    
    /* Borders */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: var(--space-md) var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.app-header .logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.app-header .subtitle {
    font-size: 0.875rem;
    opacity: 0.8;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg);
    flex: 1;
}

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

/* Form Panel */
.form-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Form Sections - Collapsible */
.form-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 0;
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.form-section legend {
    font-weight: 600;
    color: var(--primary);
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    width: 100%;
    margin: 0;
    user-select: none;
    transition: background 0.2s;
}

.form-section legend:hover {
    background: var(--gray-100);
}

.form-section legend::after {
    content: '▼';
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    color: var(--gray-400);
}

.form-section.collapsed legend::after {
    transform: rotate(-90deg);
}

.form-section .section-content {
    padding: var(--space-lg);
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    max-height: 2000px;
    opacity: 1;
}

.form-section.collapsed .section-content {
    max-height: 0;
    padding: 0 var(--space-lg);
    opacity: 0;
    overflow: hidden;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(10, 61, 98, 0.1);
}

.form-group input[readonly] {
    background: var(--gray-100);
    color: var(--gray-600);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.help-text {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Search Input */
.search-input {
    display: flex;
    gap: var(--space-sm);
}

.search-input input {
    flex: 1;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.checkbox-group.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
}

.checkbox-group.vertical {
    flex-direction: column;
    gap: var(--space-sm);
}

.checkbox-group.vertical .checkbox-label {
    padding: var(--space-sm) var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    transition: background 0.2s ease;
}

.checkbox-group.vertical .checkbox-label:hover {
    background: var(--gray-100);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Info Box */
.info-box {
    background: var(--info);
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--info);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

.info-box p {
    color: var(--gray-700);
    font-size: 0.875rem;
    margin: 0;
}

/* Jurisdiction Selector Section */
.jurisdiction-section {
    background: linear-gradient(135deg, rgba(10, 61, 98, 0.03) 0%, rgba(10, 61, 98, 0.08) 100%);
    border: 2px solid var(--primary-light);
}

.jurisdiction-section legend {
    background: var(--primary);
    color: var(--white);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.jurisdiction-select {
    font-size: 1.1rem;
    padding: var(--space-md) !important;
    background: var(--white);
    border: 2px solid var(--primary-light) !important;
    cursor: pointer;
}

.jurisdiction-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 4px rgba(10, 61, 98, 0.15) !important;
}

.jurisdiction-select option {
    padding: var(--space-sm);
}

.jurisdiction-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--primary);
    color: var(--white);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.jurisdiction-info-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-top: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
}

.jurisdiction-info-banner .flag {
    font-size: 1.25rem;
}

.jurisdiction-info-banner .regulator {
    opacity: 0.9;
}

/* Jurisdiction-specific accent colors (optional) */
[data-jurisdiction="AU-WA"] .jurisdiction-section {
    border-color: #00843D; /* Australian green */
}

[data-jurisdiction="NZ"] .jurisdiction-section {
    border-color: #00247D; /* NZ blue */
}

[data-jurisdiction="SG"] .jurisdiction-section {
    border-color: #EF3340; /* Singapore red */
}

[data-jurisdiction="US-CA"] .jurisdiction-section {
    border-color: #3C3B6E; /* US blue */
}

[data-jurisdiction="JP"] .jurisdiction-section {
    border-color: #BC002D; /* Japan red */
}

/* Jurisdiction Help Row */
.jurisdiction-help-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

/* Link Button (subtle clickable text) */
.link-button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    transition: all 0.2s ease;
    font-family: inherit;
}

.link-button:hover {
    background: rgba(10, 61, 98, 0.08);
    color: var(--primary-dark);
    text-decoration: underline;
}

.link-button:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.link-button .link-icon {
    font-size: 1rem;
}

/* Approval Process Modal */
.approval-process-modal {
    max-width: 700px;
}

.approval-process-content {
    padding: var(--space-sm) 0;
}

.approval-process-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--gray-200);
}

.approval-process-header .flag {
    font-size: 2.5rem;
}

.approval-process-header .jurisdiction-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.approval-process-header .regulator-name {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-top: var(--space-xs);
}

/* Process Steps */
.approval-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

.approval-step {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    position: relative;
}

.approval-step:not(:last-child) {
    border-bottom: 1px solid var(--gray-100);
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-action {
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
    line-height: 1.4;
}

.step-timing {
    font-size: 0.8rem;
    color: var(--gray-500);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--gray-100);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-sm);
}

.step-timing::before {
    content: "⏱️";
    font-size: 0.75rem;
}

/* Regulatory Info Section */
.regulatory-info {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-lg);
    border-left: 4px solid var(--primary);
}

.regulatory-info h4 {
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.regulatory-info p {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin: 0;
    line-height: 1.5;
}

.regulatory-info .contact-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.regulatory-info .contact-link:hover {
    text-decoration: underline;
}

/* Calculated Section */
.calculated-section {
    background: var(--gray-50);
}

.requirement-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
}

@media (max-width: 768px) {
    .requirement-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

.requirement-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
}

.requirement-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: var(--space-xs);
}

.requirement-card p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.requirement-card.capture-yes,
.requirement-card.sap-yes {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.requirement-card.capture-no,
.requirement-card.sap-no {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.requirement-card.risk-high {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.requirement-card.risk-low {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.requirement-card.risk-moderate {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

/* Warning Messages */
.warning-messages {
    margin-top: var(--space-md);
}

.warning-message {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    color: var(--gray-700);
    font-size: 0.875rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--gray-200);
}

/* Buttons */
.btn {
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-accent {
    background: var(--accent);
    color: var(--white);
}

.btn-accent:hover {
    background: var(--accent-hover);
}

/* Output Panel */
.output-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
}

.output-tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    padding: var(--space-xs);
    gap: var(--space-xs);
}

.tab-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--gray-800);
    background: var(--white);
    border-color: var(--gray-200);
}

.tab-btn.active {
    color: var(--primary);
    background: var(--white);
    border-color: var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.output-actions {
    padding: var(--space-md);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.output-actions .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

.output-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

.placeholder-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--gray-400);
    text-align: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: var(--space-sm);
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

/* ============================================
   WMS Document Styles
   ============================================ */

.wms-document {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    color: #333;
    max-width: 800px;
    margin: 0 auto;
}

/* Cover Page */
.wms-cover {
    text-align: center;
    padding: 60px 40px;
    min-height: 700px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

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

.doc-number {
    font-size: 10pt;
    color: #666;
}

.revision-date {
    font-size: 10pt;
    color: #666;
}

.cover-title h1 {
    font-size: 24pt;
    color: var(--primary);
    margin-bottom: 10px;
}

.cover-title h2 {
    font-size: 18pt;
    color: var(--primary);
    margin-bottom: 30px;
}

.cover-title h3 {
    font-size: 16pt;
    color: #333;
    margin-bottom: 10px;
}

.job-number {
    font-size: 14pt;
    font-weight: bold;
    margin-top: 20px;
}

.cover-footer {
    margin-top: auto;
}

.confidential {
    font-size: 12pt;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 10px;
}

.website {
    font-size: 10pt;
    color: #666;
}

/* Table of Contents */
.wms-toc {
    padding: 40px;
}

.wms-toc h2 {
    font-size: 14pt;
    color: var(--primary);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

.toc-list {
    list-style: none;
    padding: 0;
}

.toc-list li {
    padding: 8px 0;
    border-bottom: 1px dotted var(--gray-300);
}

.toc-list a {
    color: #333;
    text-decoration: none;
}

/* WMS Sections */
.wms-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--gray-200);
}

.wms-section h2 {
    font-size: 14pt;
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
}

.wms-section h3 {
    font-size: 12pt;
    color: var(--primary-dark);
    margin: 20px 0 10px;
    text-transform: uppercase;
}

.wms-section p {
    margin-bottom: 12px;
}

.wms-section ul,
.wms-section ol {
    margin: 10px 0 15px 25px;
}

.wms-section li {
    margin-bottom: 6px;
}

/* WMS Tables */
.wms-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 10pt;
}

.wms-table caption {
    text-align: left;
    font-weight: bold;
    padding: 8px 0;
    color: var(--gray-700);
}

.wms-table th,
.wms-table td {
    border: 1px solid var(--gray-300);
    padding: 8px 12px;
    text-align: left;
}

.wms-table th {
    background: var(--gray-100);
    font-weight: 600;
}

.wms-table tr:nth-child(even) {
    background: var(--gray-50);
}

/* Checklist Table */
.checklist-table .status-confirmed {
    color: var(--success);
    font-weight: 600;
}

.checklist-table .status-pending {
    color: var(--warning);
    font-weight: 600;
}

.checklist-table .status-incomplete {
    color: var(--danger);
    font-weight: 600;
}

/* Decision Framework */
.decision-framework {
    margin: 20px 0;
}

.framework-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: 15px 20px;
    margin-bottom: 10px;
}

.framework-box h4 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 11pt;
}

.framework-arrow {
    text-align: center;
    font-size: 20pt;
    color: var(--primary);
    margin: 5px 0;
}

.check-list {
    list-style: none;
    padding: 0;
}

.check-list li {
    padding: 4px 0 4px 25px;
    position: relative;
}

.check-list li::before {
    position: absolute;
    left: 0;
    font-weight: bold;
}

.check-list li.check-pass::before {
    content: "✓";
    color: var(--success);
}

.check-list li.check-fail::before {
    content: "✗";
    color: var(--danger);
}

.check-list li.check-pending::before {
    content: "○";
    color: var(--warning);
}

.requirements-table {
    width: 100%;
    margin-top: 10px;
}

.requirements-table td {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
}

.requirements-table td.required {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    font-weight: 600;
}

.requirements-table td.not-required {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    font-weight: 600;
}

/* Warning Box */
.warning-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 15px 20px;
    margin: 20px 0;
}

.warning-box h4 {
    color: var(--danger);
    margin-bottom: 10px;
}

/* Document Control */
.document-control {
    margin-top: 40px;
}

.control-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 10pt;
}

.control-table th,
.control-table td {
    border: 1px solid var(--gray-300);
    padding: 8px 12px;
    text-align: left;
}

.control-table th {
    background: var(--gray-100);
    width: 150px;
}

.copyright-notice {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-300);
    font-size: 9pt;
    color: var(--gray-600);
}

.copyright-notice h4 {
    color: var(--gray-700);
    margin-bottom: 10px;
}

.copyright-notice p {
    margin-bottom: 8px;
}

.copyright-year {
    font-weight: bold;
    margin-top: 15px;
}

/* Appendix List */
.appendix-list {
    list-style: none;
    padding: 0;
}

.appendix-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
}

/* Email Content */
.email-content {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
}

.email-content h3 {
    color: var(--primary);
    margin: 20px 0 10px;
    font-size: 16px;
}

.email-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.email-table th,
.email-table td {
    border: 1px solid var(--gray-300);
    padding: 8px 12px;
    text-align: left;
}

.email-table th {
    background: var(--gray-100);
    font-weight: 600;
    width: 180px;
}

/* Page Break Helpers */
.page-break-before {
    page-break-before: always;
}

.page-break-after {
    page-break-after: always;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white;
        font-size: 11pt;
    }

    .app-container {
        display: block;
    }

    .main-content {
        display: block;
        padding: 0;
    }

    .form-panel {
        display: none !important;
    }

    /* CRITICAL: Override mobile styles that hide output panel */
    .output-panel {
        position: static !important;
        transform: none !important;
        box-shadow: none;
        border-radius: 0;
        max-height: none !important;
        height: auto !important;
        width: 100% !important;
        display: block !important;
        overflow: visible !important;
    }

    .output-content {
        padding: 0;
        overflow: visible !important;
        height: auto !important;
    }
    
    .output-tabs,
    .output-actions {
        display: none !important;
    }

    .wms-document {
        max-width: none;
    }

    .wms-section {
        page-break-inside: avoid;
    }

    .wms-cover {
        height: 100vh;
    }

    .page-break-before {
        page-break-before: always;
    }

    .page-break-after {
        page-break-after: always;
    }
}

/* Saved Jobs List */
.saved-job-item {
    padding: var(--space-md);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.saved-job-item:hover {
    background: var(--gray-50);
}

.saved-job-info h4 {
    font-size: 1rem;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
}

.saved-job-info p {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.saved-job-actions {
    display: flex;
    gap: var(--space-sm);
}

.btn-delete {
    background: var(--danger);
    color: var(--white);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
}

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

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Vessel Search Modal
   ============================================ */

/* Vessel search modal uses inline display style instead of .active class */
#vesselSearchModal {
    align-items: center;
    justify-content: center;
}

#vesselSearchModal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
}

#vesselSearchModal .modal-content,
.vessel-search-modal {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--white);
    font-weight: 600;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding: var(--space-lg);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Search Status */
.search-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xl);
    color: var(--gray-500);
}

.search-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Vessel Results Grid */
.vessel-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-md);
}

.vessel-result-card {
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.vessel-result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: transform 0.2s;
}

.vessel-result-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(10, 61, 98, 0.15);
    transform: translateY(-2px);
}

.vessel-result-card:hover::before {
    transform: scaleY(1);
}

.vessel-result-card.selected {
    border-color: var(--success);
    background: #f0fdf4;
}

.vessel-result-card.selected::before {
    background: var(--success);
    transform: scaleY(1);
}

.vessel-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.vessel-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.vessel-card-flag {
    font-size: 0.75rem;
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.vessel-card-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs) var(--space-md);
    font-size: 0.85rem;
}

.vessel-detail-row {
    display: flex;
    gap: var(--space-xs);
}

.vessel-detail-label {
    color: var(--gray-500);
    font-weight: 500;
}

.vessel-detail-value {
    color: var(--gray-800);
}

.vessel-card-type {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--gray-100);
    font-size: 0.8rem;
    color: var(--gray-500);
}

.vessel-select-btn {
    position: absolute;
    bottom: var(--space-md);
    right: var(--space-md);
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s;
}

.vessel-result-card:hover .vessel-select-btn {
    opacity: 1;
    transform: translateY(0);
}

.vessel-select-btn:hover {
    background: var(--primary-dark);
}

/* No Results */
.no-results {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--gray-500);
}

.no-results p {
    margin: var(--space-sm) 0;
}

/* Local Vessel Section */
.local-vessels-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 2px dashed var(--gray-200);
}

.local-vessels-title {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.local-vessels-title::before {
    content: '💾';
}

/* Results Count */
.results-count {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--gray-100);
}

.results-count strong {
    color: var(--primary);
}

/* ============================================
   Settings Modal
   ============================================ */

.settings-modal {
    max-width: 600px;
}

.settings-info {
    background: var(--gray-50);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border-left: 3px solid var(--info);
}

.settings-info p {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.settings-section {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--gray-100);
}

.settings-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-section h3 {
    margin: 0 0 var(--space-xs) 0;
    color: var(--primary-dark);
    font-size: 1.1rem;
}

.settings-description {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin: 0 0 var(--space-md) 0;
}

.api-key-input {
    display: flex;
    gap: var(--space-sm);
}

.api-key-input input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.api-key-input .btn-icon {
    padding: var(--space-sm) var(--space-md);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.api-key-input .btn-icon:hover {
    background: var(--gray-200);
}

.settings-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: #fef3c7;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #92400e;
}

.settings-note code {
    background: rgba(0,0,0,0.1);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: var(--font-mono);
}

.deployment-status {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--gray-100);
}

.status-item:last-child {
    border-bottom: none;
}

.status-label {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.status-value {
    font-weight: 500;
    font-size: 0.9rem;
}

.status-value.connected {
    color: var(--success);
}

.status-value.disconnected {
    color: var(--danger);
}

.status-value.partial {
    color: var(--warning);
}

/* Icon Button in Header */
.btn-icon {
    padding: var(--space-sm) var(--space-md);
    font-size: 1.2rem;
    line-height: 1;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

/* Help text links */
.help-text a {
    color: var(--info);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

/* Success button state */
.btn-success {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: white !important;
}

/* ============================================
   Image Upload Styles
   ============================================ */

.image-upload-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.image-upload-input {
    display: none;
}

.image-preview {
    width: 100%;
    min-height: 100px;
    max-height: 150px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--gray-50);
    overflow: hidden;
    position: relative;
}

.image-preview:hover {
    border-color: var(--primary);
    background: var(--gray-100);
}

.image-preview.has-image {
    border-style: solid;
    border-color: var(--success);
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-preview .placeholder-text {
    color: var(--gray-400);
    font-size: 0.9rem;
    text-align: center;
    padding: var(--space-md);
}

.image-preview.vessel-preview {
    min-height: 150px;
    max-height: 200px;
}

.image-preview.ga-preview {
    min-height: 150px;
    max-height: 200px;
}

.btn-small {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
}

/* ============================================
   Document Templates - Additional Styles
   ============================================ */

/* Cover page with logo */
.wms-cover .cover-logo {
    text-align: center;
    padding: var(--space-xl) 0;
}

.wms-cover .cover-logo .company-logo {
    max-width: 200px;
    max-height: 80px;
    object-fit: contain;
}

.wms-cover .vessel-image-container {
    text-align: center;
    margin: var(--space-xl) auto;
    max-width: 400px;
}

.wms-cover .vessel-image {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* General Arrangement Image */
.ga-image-container {
    text-align: center;
    margin: var(--space-lg) auto;
    padding: var(--space-md);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.ga-image {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.wms-cover .doc-type {
    font-size: 0.9rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: var(--space-md);
}

/* ERP-specific styles */
.erp-document .contacts-table {
    margin-bottom: var(--space-lg);
}

.erp-document .contact-emergency {
    background: var(--danger);
    color: white;
    font-weight: bold;
}

.erp-document .contact-emergency td {
    padding: var(--space-md);
}

.erp-document .contact-highlight {
    background: var(--warning);
    font-weight: 600;
}

.erp-document .procedure-box {
    background: var(--gray-50);
    border-left: 4px solid var(--primary);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.erp-document .procedure-box.warning {
    border-left-color: var(--danger);
    background: #fff5f5;
}

.erp-document .procedure-box ol {
    margin-left: var(--space-lg);
}

.erp-document .procedure-box li {
    margin-bottom: var(--space-sm);
}

.erp-document .hospital-info,
.erp-document .hospital-directions {
    background: var(--info);
    color: white;
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin: var(--space-lg) 0;
}

.erp-document .hospital-info h3,
.erp-document .hospital-directions h3 {
    color: white;
    margin-bottom: var(--space-sm);
}

/* WHSMP-specific styles */
.whsmp-document .risk-matrix {
    font-size: 0.85rem;
}

.whsmp-document .risk-matrix th,
.whsmp-document .risk-matrix td {
    text-align: center;
    padding: var(--space-sm);
}

.whsmp-document .risk-low {
    background: #d1fae5;
    color: #065f46;
}

.whsmp-document .risk-medium {
    background: #fef3c7;
    color: #92400e;
}

.whsmp-document .risk-high {
    background: #fed7aa;
    color: #9a3412;
}

.whsmp-document .risk-extreme {
    background: #fecaca;
    color: #991b1b;
    font-weight: bold;
}

.whsmp-document .hierarchy-list {
    counter-reset: hierarchy;
    list-style: none;
    padding-left: 0;
}

.whsmp-document .hierarchy-list li {
    counter-increment: hierarchy;
    padding: var(--space-sm) var(--space-md);
    margin: var(--space-xs) 0;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: var(--radius-sm);
}

.whsmp-document .hierarchy-list li:nth-child(2) {
    opacity: 0.9;
}

.whsmp-document .hierarchy-list li:nth-child(3) {
    opacity: 0.8;
}

.whsmp-document .hierarchy-list li:nth-child(4) {
    opacity: 0.7;
}

.whsmp-document .hierarchy-list li:nth-child(5) {
    opacity: 0.6;
}

.whsmp-document .hierarchy-list li:nth-child(6) {
    opacity: 0.5;
}

/* SWMS-specific styles */
.swms-document {
    font-size: 0.9rem;
}

.swms-document .swms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--primary);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-lg);
}

.swms-document .swms-logo .company-logo {
    max-height: 60px;
}

.swms-document .swms-title-block {
    text-align: right;
}

.swms-document .swms-title-block h1 {
    font-size: 1.2rem;
    color: var(--primary);
}

.swms-document .swms-title-block h2 {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: normal;
}

.swms-document .swms-section {
    margin-bottom: var(--space-lg);
}

.swms-document .swms-section h3 {
    background: var(--primary);
    color: white;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    font-size: 0.95rem;
}

.swms-document .swms-info-table {
    width: 100%;
    border-collapse: collapse;
}

.swms-document .swms-info-table td {
    padding: var(--space-sm);
    border: 1px solid var(--gray-300);
}

.swms-document .swms-check-table {
    width: 100%;
}

.swms-document .swms-check-table td {
    padding: var(--space-sm);
}

.swms-document .swms-check-table td:first-child {
    width: 30px;
    font-size: 1.2rem;
}

.swms-document .swms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.swms-document .swms-table th,
.swms-document .swms-table td {
    padding: var(--space-sm);
    border: 1px solid var(--gray-300);
    text-align: left;
}

.swms-document .swms-table th {
    background: var(--gray-100);
}

.swms-document .swms-hazard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.swms-document .swms-hazard-table th,
.swms-document .swms-hazard-table td {
    padding: var(--space-sm);
    border: 1px solid var(--gray-300);
    vertical-align: top;
}

.swms-document .swms-hazard-table th {
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
}

.swms-document .swms-hazard-table .risk-low {
    background: #d1fae5;
    color: #065f46;
    text-align: center;
    font-weight: 600;
}

.swms-document .swms-hazard-table .risk-medium {
    background: #fef3c7;
    color: #92400e;
    text-align: center;
    font-weight: 600;
}

.swms-document .swms-hazard-table .risk-high {
    background: #fed7aa;
    color: #9a3412;
    text-align: center;
    font-weight: 600;
}

.swms-document .swms-hazard-table .risk-extreme {
    background: #fecaca;
    color: #991b1b;
    text-align: center;
    font-weight: 600;
}

.swms-document .ppe-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
}

.swms-document .ppe-item {
    background: var(--gray-100);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.swms-document .swms-signoff-table {
    width: 100%;
    border-collapse: collapse;
}

.swms-document .swms-signoff-table th,
.swms-document .swms-signoff-table td {
    padding: var(--space-md);
    border: 1px solid var(--gray-300);
}

.swms-document .swms-signoff-table th {
    background: var(--gray-100);
    width: 33%;
}

.swms-document .swms-signoff-table td {
    height: 40px;
}

/* ============================================
   Enhanced SWMS Styles (Comprehensive)
   ============================================ */

/* SWMS Header Info Grid */
.swms-document .swms-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.swms-document .swms-info-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.swms-document .swms-info-block h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
    border-bottom: 2px solid var(--primary);
    padding-bottom: var(--space-xs);
}

/* Equipment Checkboxes Grid */
.swms-document .equipment-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-xs);
    font-size: 0.75rem;
}

.swms-document .equipment-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 6px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 3px;
}

.swms-document .equipment-item.checked {
    background: #d1fae5;
    border-color: #10b981;
}

/* Dive Parameters */
.swms-document .dive-params {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--gray-200);
}

.swms-document .dive-param {
    text-align: center;
}

.swms-document .dive-param label {
    display: block;
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
}

.swms-document .dive-param .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

/* Documentation Checklist Grid */
.swms-document .documentation-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.swms-document .doc-column {
    font-size: 0.7rem;
}

.swms-document .doc-column h5 {
    font-size: 0.7rem;
    color: var(--primary);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--primary);
}

.swms-document .doc-column .check-item {
    display: flex;
    gap: 4px;
    margin-bottom: 2px;
    line-height: 1.3;
}

/* Hazard Category Grids */
.swms-document .hazard-category-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    font-size: 0.7rem;
}

.swms-document .hazard-category {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
}

.swms-document .hazard-category h5 {
    font-size: 0.7rem;
    color: var(--primary-dark);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
}

.swms-document .hazard-category .check-item {
    display: flex;
    gap: 4px;
    margin-bottom: 2px;
}

/* Contacts Grid */
.swms-document .contacts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.swms-document .contact-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
}

.swms-document .contact-block h5 {
    font-size: 0.75rem;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.swms-document .contact-block table {
    width: 100%;
    font-size: 0.7rem;
}

.swms-document .contact-block td {
    padding: 2px 0;
}

.swms-document .contact-block .phone {
    font-weight: 600;
    color: var(--gray-800);
}

/* Risk Assessment Matrix */
.swms-document .risk-matrix-section {
    background: var(--gray-50);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.swms-document .risk-matrix-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-lg);
}

.swms-document .consequence-table,
.swms-document .probability-table,
.swms-document .risk-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}

.swms-document .consequence-table th,
.swms-document .consequence-table td,
.swms-document .probability-table th,
.swms-document .probability-table td,
.swms-document .risk-matrix-table th,
.swms-document .risk-matrix-table td {
    border: 1px solid var(--gray-300);
    padding: 4px 6px;
    text-align: center;
}

.swms-document .consequence-table th,
.swms-document .probability-table th {
    background: var(--primary);
    color: white;
}

.swms-document .risk-matrix-table th {
    background: var(--gray-700);
    color: white;
}

/* Risk Level Colors in Matrix */
.swms-document .risk-E { background: #991b1b; color: white; font-weight: 700; }
.swms-document .risk-H { background: #ea580c; color: white; font-weight: 600; }
.swms-document .risk-M { background: #f59e0b; color: #000; font-weight: 600; }
.swms-document .risk-L { background: #22c55e; color: white; font-weight: 500; }

/* Risk Legend */
.swms-document .risk-legend {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.swms-document .legend-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    font-size: 0.7rem;
}

.swms-document .legend-badge {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: 700;
    flex-shrink: 0;
}

.swms-document .legend-badge.E { background: #991b1b; color: white; }
.swms-document .legend-badge.H { background: #ea580c; color: white; }
.swms-document .legend-badge.M { background: #f59e0b; color: #000; }
.swms-document .legend-badge.L { background: #22c55e; color: white; }

/* Hazard Section Part Headers */
.swms-document .part-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-xl) 0 var(--space-lg) 0;
    border-radius: var(--radius-md);
}

.swms-document .part-header h2 {
    margin: 0;
    font-size: 1.1rem;
    border: none;
    padding: 0;
    color: white;
}

/* Comprehensive Hazard Table */
.swms-document .hazard-table-comprehensive {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.65rem;
    margin-bottom: var(--space-lg);
}

.swms-document .hazard-table-comprehensive th {
    background: var(--primary);
    color: white;
    padding: 6px 4px;
    text-align: center;
    font-size: 0.6rem;
    border: 1px solid var(--primary-dark);
}

.swms-document .hazard-table-comprehensive td {
    padding: 4px;
    border: 1px solid var(--gray-300);
    vertical-align: top;
}

.swms-document .hazard-table-comprehensive tr:nth-child(even) {
    background: var(--gray-50);
}

.swms-document .hazard-table-comprehensive .section-header {
    background: var(--gray-700);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.swms-document .hazard-table-comprehensive .section-header td {
    padding: 8px;
    border-color: var(--gray-800);
}

/* Risk columns in hazard table */
.swms-document .hazard-table-comprehensive .col-c,
.swms-document .hazard-table-comprehensive .col-p,
.swms-document .hazard-table-comprehensive .col-risk {
    text-align: center;
    width: 30px;
}

.swms-document .hazard-table-comprehensive .col-controls {
    width: 30%;
}

/* Table of Contents */
.swms-document .toc-section {
    background: var(--gray-50);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xl);
}

.swms-document .toc-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.swms-document .toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
}

.swms-document .toc-list li {
    padding: 4px 0;
    border-bottom: 1px dotted var(--gray-300);
}

.swms-document .toc-list li a {
    color: var(--gray-700);
    text-decoration: none;
}

.swms-document .toc-list li.toc-part {
    font-weight: 600;
    color: var(--primary);
    margin-top: var(--space-sm);
}

/* Worker Sign-off Table Enhanced */
.swms-document .worker-signoff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.swms-document .worker-signoff-table th {
    background: var(--primary);
    color: white;
    padding: var(--space-sm);
    text-align: left;
}

.swms-document .worker-signoff-table td {
    padding: var(--space-sm);
    border: 1px solid var(--gray-300);
    height: 28px;
}

.swms-document .worker-signoff-table tr:nth-child(even) {
    background: var(--gray-50);
}

/* Legislative References Table */
.swms-document .legislation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.swms-document .legislation-table th {
    background: var(--gray-700);
    color: white;
    padding: var(--space-sm);
    text-align: left;
}

.swms-document .legislation-table td {
    padding: var(--space-sm);
    border: 1px solid var(--gray-300);
}

.swms-document .legislation-table tr:nth-child(even) {
    background: var(--gray-50);
}

/* Document Approval Section */
.swms-document .approval-section {
    background: var(--gray-50);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-top: var(--space-xl);
}

.swms-document .approval-table {
    width: 100%;
    border-collapse: collapse;
}

.swms-document .approval-table th {
    background: var(--primary);
    color: white;
    padding: var(--space-md);
    text-align: left;
}

.swms-document .approval-table td {
    padding: var(--space-md);
    border: 1px solid var(--gray-300);
    min-width: 120px;
}

/* Emergency Contacts Enhanced */
.swms-document .emergency-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}

.swms-document .emergency-box {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.swms-document .emergency-box.primary {
    border-color: var(--danger);
    background: #fff5f5;
}

.swms-document .emergency-box h5 {
    font-size: 0.8rem;
    color: var(--primary-dark);
    margin-bottom: var(--space-sm);
}

.swms-document .emergency-box .phone-big {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--danger);
}

/* Print adjustments for comprehensive SWMS */
@media print {
    .swms-document .equipment-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .swms-document .hazard-category-grid {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .swms-document .documentation-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .swms-document .risk-matrix-grid {
        grid-template-columns: 2fr 1fr 1fr;
    }
    
    .swms-document .hazard-table-comprehensive {
        font-size: 6pt;
    }
    
    .swms-document .part-header {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .swms-document .risk-E,
    .swms-document .risk-H,
    .swms-document .risk-M,
    .swms-document .risk-L {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Print styles for all documents */
@media print {
    .wms-cover .cover-logo,
    .wms-cover .vessel-image-container,
    .swms-header .swms-logo {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .wms-cover .company-logo,
    .wms-cover .vessel-image,
    .swms-header .company-logo {
        max-width: 100% !important;
    }
    
    .erp-document .contact-emergency,
    .erp-document .contact-highlight,
    .erp-document .hospital-info,
    .erp-document .hospital-directions,
    .whsmp-document .risk-matrix td,
    .swms-document .swms-hazard-table td {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .swms-document .ppe-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   Form Enhancements - Progress & Autosave
   ============================================ */

/* Progress Container */
.progress-container {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    font-size: 0.875rem;
    color: var(--gray-600);
}

.progress-label span:last-child {
    font-weight: 600;
    color: var(--primary);
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-sections {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-sm);
    padding: 0 var(--space-xs);
}

.progress-section {
    font-size: 0.75rem;
    color: var(--gray-400);
    cursor: default;
}

.progress-section.partial {
    color: var(--warning);
}

.progress-section.complete {
    color: var(--success);
}

/* Autosave Indicator */
.autosave-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gray-800);
    color: var(--white);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.autosave-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

.autosave-icon {
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Validation Styles */
.required-star {
    color: var(--danger);
    font-weight: 600;
}

.field-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.field-valid {
    border-color: var(--success) !important;
}

.field-error-message {
    display: block;
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: var(--space-xs);
}

/* Notifications */
.form-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-success {
    background: var(--success);
    color: var(--white);
}

.notification-warning {
    background: var(--warning);
    color: var(--gray-900);
}

.notification-error {
    background: var(--danger);
    color: var(--white);
}

.notification-info {
    background: var(--info);
    color: var(--white);
}

.notification-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    margin-left: var(--space-sm);
    opacity: 0.7;
}

.notification-close:hover {
    opacity: 1;
}

/* ============================================
   Fouling Rating Slider
   ============================================ */

.fouling-slider-container {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-top: var(--space-sm);
}

.fouling-display {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.fouling-hull {
    position: relative;
    width: 200px;
    height: 60px;
    --fouling-color: #22c55e;
}

.fouling-hull svg {
    width: 100%;
    height: 100%;
    color: var(--gray-300);
    transition: color 0.3s ease;
}

.fouling-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 30px;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.3s ease;
    mix-blend-mode: multiply;
}

.hull-shape {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.fouling-info {
    flex: 1;
}

.fouling-rating {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    transition: color 0.3s ease;
}

.fouling-desc {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: var(--space-xs);
}

.fouling-slider-track {
    position: relative;
    padding: 0 8px;
}

.fouling-slider-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    background: linear-gradient(90deg, 
        #22c55e 0%, 
        #84cc16 10%, 
        #a3e635 20%, 
        #facc15 35%, 
        #f59e0b 50%, 
        #ea580c 65%, 
        #dc2626 80%, 
        #7f1d1d 100%
    );
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.fouling-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--white);
    border: 3px solid var(--primary);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
}

.fouling-slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.fouling-slider-input::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.fouling-slider-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--white);
    border: 3px solid var(--primary);
    border-radius: 50%;
    cursor: grab;
    box-shadow: var(--shadow-md);
}

.fouling-ticks {
    position: relative;
    height: 30px;
    margin-top: var(--space-sm);
}

.fouling-tick {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tick-mark {
    width: 4px;
    height: 10px;
    border-radius: 2px;
}

.tick-label {
    font-size: 0.625rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.fouling-legend {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--gray-200);
    font-size: 0.75rem;
    color: var(--gray-600);
}

/* ============================================
   Modal Styles
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-800);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ============================================
   Print Preview Modal
   ============================================ */

.print-preview-modal .modal-content {
    width: 90vw;
    height: 90vh;
}

.print-preview-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.preview-title {
    flex: 1;
}

.preview-doc-name {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-left: var(--space-sm);
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--gray-600);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.print-preview-body {
    flex: 1;
    padding: 0;
    background: var(--gray-300);
    overflow: hidden;
}

.preview-scroll-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: var(--space-lg);
}

.preview-page-container {
    background: var(--white);
    box-shadow: var(--shadow-lg);
    margin: 0 auto;
    min-width: 210mm;
}

.preview-frame {
    width: 100%;
    min-height: 297mm;
    border: none;
    background: var(--white);
    transform-origin: top center;
}

.print-preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-info {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.preview-actions {
    display: flex;
    gap: var(--space-sm);
}

/* ============================================
   Button Variants
   ============================================ */

.btn-delete {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: var(--white);
}

.btn-small {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
}

/* ============================================
   Collapsible Sections (Enhanced)
   ============================================ */

.form-section legend {
    cursor: pointer;
    position: relative;
    padding-right: 30px;
    user-select: none;
    transition: color 0.2s;
}

.form-section legend:hover {
    color: var(--primary);
}

.form-section legend::after {
    content: '▼';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--gray-400);
    transition: transform 0.3s ease;
}

.form-section.collapsed legend::after {
    transform: translateY(-50%) rotate(-90deg);
}

.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out;
    max-height: 2000px;
    opacity: 1;
}

.form-section.collapsed .section-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* ============================================
   Print Overrides for Enhancements
   ============================================ */

@media print {
    .progress-container,
    .autosave-indicator,
    .form-notification,
    .modal {
        display: none !important;
    }
}

/* ============================================
   User Menu & Authentication
   ============================================ */

.user-menu {
    position: relative;
    display: none;
}

.header-actions.authenticated .user-menu {
    display: flex;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.dropdown-arrow {
    font-size: 0.625rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.user-menu-dropdown.active + .dropdown-arrow,
.user-menu-trigger[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-menu-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info strong {
    display: block;
    color: var(--gray-800);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info span {
    display: block;
    color: var(--gray-500);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-items {
    padding: var(--space-sm) 0;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.user-menu-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.user-menu-item.text-danger {
    color: var(--danger);
}

.user-menu-item.text-danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

.user-menu-divider {
    height: 1px;
    background: var(--gray-200);
    margin: var(--space-sm) 0;
}

/* Login Button in Header */
.header-actions #loginBtn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
}

/* Hide elements based on auth state */
.header-actions:not(.authenticated) #userMenu {
    display: none;
}

.header-actions.authenticated #loginBtn {
    display: none !important;
}

/* ============================================
   Dashboard Styles (placeholder)
   ============================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.dashboard-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.dashboard-card h3 {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-stat {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.dashboard-stat.text-success { color: var(--success); }
.dashboard-stat.text-warning { color: var(--warning); }
.dashboard-stat.text-danger { color: var(--danger); }

/* ============================================
   Dashboard Modal
   ============================================ */

.dashboard-modal .modal-content {
    width: 700px;
    max-width: 95vw;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.dashboard-section {
    margin-bottom: var(--space-xl);
}

.dashboard-section h3 {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--gray-200);
}

.recent-jobs-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.job-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.job-card:hover {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.job-card-main {
    flex: 1;
}

.job-card-title {
    font-weight: 600;
    color: var(--gray-800);
}

.job-card-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: var(--space-xs);
}

.job-card-date {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.quick-actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ============================================
   My Jobs Modal
   ============================================ */

.my-jobs-modal .modal-content {
    width: 900px;
    max-width: 95vw;
    max-height: 90vh;
}

.jobs-toolbar {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.jobs-toolbar .search-box {
    flex: 1;
}

.jobs-toolbar .search-box input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.jobs-toolbar .sort-options select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background: var(--white);
}

.jobs-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-height: 60vh;
    overflow-y: auto;
}

.job-card-full {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.job-card-full:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.job-card-left {
    flex: 1;
}

.job-card-full .job-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-xs);
}

.job-card-details {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-bottom: var(--space-sm);
}

.job-tag {
    display: inline-block;
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.job-client {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.job-imo {
    color: var(--gray-500);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.job-card-dates {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.job-card-actions {
    display: flex;
    gap: var(--space-sm);
}

.btn-small {
    padding: var(--space-xs) var(--space-sm) !important;
    font-size: 0.75rem !important;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
    border: none;
}

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

.empty-state {
    text-align: center;
    color: var(--gray-500);
    padding: var(--space-xl);
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ============================================ */

/* Tablet Breakpoint */
@media (max-width: 1024px) {
    .main-content {
        padding: var(--space-md);
        gap: var(--space-md);
    }
    
    .form-panel {
        padding: var(--space-lg);
    }
}

/* Mobile Breakpoint - Primary */
@media (max-width: 768px) {
    /* Typography Scale for Mobile */
    html {
        font-size: 15px;
    }
    
    /* Header - Mobile Optimized */
    .app-header {
        padding: var(--space-sm) var(--space-md);
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .app-header .logo h1 {
        font-size: 1.125rem;
        line-height: 1.2;
    }
    
    .app-header .subtitle {
        font-size: 0.75rem;
        display: none; /* Hide on mobile to save space */
    }
    
    .header-actions {
        flex-wrap: wrap;
        gap: var(--space-xs);
    }
    
    .header-actions .btn {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.8125rem;
    }
    
    /* Hide text labels on mobile header buttons, show icons only */
    .header-actions .btn-primary,
    .header-actions .btn-secondary {
        min-width: auto;
    }
    
    /* Main Content - Stack on Mobile */
    .main-content {
        grid-template-columns: 1fr;
        padding: var(--space-sm);
        gap: var(--space-sm);
        padding-bottom: calc(80px + var(--space-md)); /* Space for mobile nav */
    }
    
    /* Form Panel - Full Width */
    .form-panel {
        padding: var(--space-md);
        border-radius: var(--radius-md);
        max-height: none; /* Remove fixed height on mobile */
        overflow: visible;
    }
    
    /* Progress Container - Compact */
    .progress-container {
        padding: var(--space-sm) var(--space-md);
        margin-bottom: var(--space-md);
    }
    
    .progress-header {
        margin-bottom: var(--space-xs);
    }
    
    .progress-header span {
        font-size: 0.75rem;
    }
    
    /* Progress Steps - Horizontal Scroll on Mobile */
    .progress-steps {
        gap: var(--space-xs);
        overflow-x: auto;
        padding-bottom: var(--space-xs);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .progress-steps::-webkit-scrollbar {
        display: none;
    }
    
    .progress-step {
        font-size: 0.625rem;
        min-width: 44px; /* Minimum touch target */
        flex-shrink: 0;
    }
    
    .progress-step::before {
        width: 20px;
        height: 20px;
        font-size: 0.625rem;
    }
    
    /* Form Sections - Better Mobile Spacing */
    .form-section {
        margin-bottom: var(--space-md);
        border-radius: var(--radius-md);
    }
    
    .form-section legend {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9375rem;
    }
    
    .form-section-content {
        padding: var(--space-md);
    }
    
    /* Form Grid - Stack on Mobile */
    .form-grid,
    .form-row {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }
    
    /* Form Groups - Better Touch Targets */
    .form-group label {
        font-size: 0.8125rem;
        margin-bottom: var(--space-xs);
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: var(--space-sm) var(--space-md);
        font-size: 1rem; /* 16px prevents zoom on iOS */
        min-height: 44px; /* iOS touch target */
        border-radius: var(--radius-md);
    }
    
    /* Checkboxes - Larger Touch Targets */
    .checkbox-group {
        gap: var(--space-md);
    }
    
    .checkbox-group label {
        padding: var(--space-sm);
        min-height: 44px;
        display: flex;
        align-items: center;
        gap: var(--space-sm);
    }
    
    .checkbox-group input[type="checkbox"] {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }
    
    /* Equipment Grid - 2 columns on mobile */
    .equipment-column {
        min-width: 100%;
    }
    
    .equipment-checkboxes {
        grid-template-columns: 1fr;
    }
    
    /* Buttons - Full Width on Mobile */
    .form-actions {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .form-actions .btn {
        width: 100%;
        padding: var(--space-md);
        font-size: 1rem;
        justify-content: center;
    }
    
    /* Output Panel - Hidden by Default on Mobile */
    .output-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        max-height: 100vh;
        overflow-y: auto;
        background: var(--white);
    }
    
    .output-panel.active {
        transform: translateY(0);
    }
    
    .output-tabs {
        flex-wrap: wrap;
        gap: var(--space-xs);
        padding: var(--space-sm);
        position: sticky;
        top: 0;
        background: var(--white);
        z-index: 10;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .tab-btn {
        flex: 1;
        min-width: 60px;
        padding: var(--space-sm);
        font-size: 0.75rem;
        min-height: 44px;
    }
    
    .output-actions {
        flex-direction: column;
        padding: var(--space-sm);
        position: sticky;
        bottom: 0;
        background: var(--white);
        gap: var(--space-sm);
    }
    
    .output-actions .btn {
        width: 100%;
    }
    
    /* Dashboard Modal - Mobile Optimized */
    .dashboard-modal .modal-content,
    .my-jobs-modal .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }
    
    .stat-card {
        padding: var(--space-md);
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .job-card-full {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }
    
    .job-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* Modals - Full Screen on Mobile */
    .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .modal-footer {
        position: sticky;
        bottom: 0;
    }
    
    /* Fouling Slider - Mobile Touch Friendly */
    .fouling-slider-container {
        padding: var(--space-sm);
    }
    
    .fouling-track {
        height: 12px;
    }
    
    .fouling-thumb {
        width: 32px;
        height: 32px;
    }
    
    /* Requirement Cards - Stack */
    .requirement-cards {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    /* Jurisdiction Info - Compact */
    .jurisdiction-info {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    /* Search Box - Full Width */
    .vessel-search-container {
        padding: var(--space-sm);
    }
    
    .vessel-search-container input {
        font-size: 1rem;
    }
}

/* Small Mobile Breakpoint */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .app-header .logo h1 {
        font-size: 1rem;
    }
    
    /* Header Actions - Icon Only */
    .header-actions .btn span:not(.icon) {
        display: none;
    }
    
    .progress-step span {
        display: none; /* Hide text, show only icons */
    }
    
    .progress-step::before {
        margin-bottom: 0;
    }
    
    .stat-card {
        padding: var(--space-sm);
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.625rem;
    }
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: var(--space-xs) var(--space-sm);
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, var(--space-xs));
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.2s;
    min-width: 64px;
}

.mobile-nav-item:hover,
.mobile-nav-item:active,
.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item .nav-icon {
    font-size: 1.25rem;
}

.mobile-nav-item .nav-label {
    white-space: nowrap;
}

/* Preview Toggle Button - Mobile Only */
.preview-toggle {
    display: none;
}

@media (max-width: 768px) {
    .preview-toggle {
        display: flex;
        position: fixed;
        bottom: calc(80px + var(--space-md));
        right: var(--space-md);
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary);
        color: var(--white);
        border: none;
        box-shadow: var(--shadow-lg);
        cursor: pointer;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        z-index: 999;
        transition: transform 0.2s, background 0.2s;
    }
    
    .preview-toggle:hover,
    .preview-toggle:active {
        transform: scale(1.05);
        background: var(--primary-dark);
    }
    
    /* Close button for output panel on mobile */
    .output-close-mobile {
        display: block;
        position: absolute;
        top: var(--space-sm);
        right: var(--space-sm);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--gray-100);
        border: none;
        font-size: 1.25rem;
        cursor: pointer;
        z-index: 11;
    }
}

/* ============================================
   TOUCH INTERACTION IMPROVEMENTS
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    /* Add active states instead */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    /* Larger click areas for interactive elements */
    .form-section legend {
        padding: var(--space-md) var(--space-lg);
    }
    
    .tab-btn {
        min-height: 44px;
    }
    
    /* Disable text selection on interactive elements */
    .btn,
    .tab-btn,
    .progress-step,
    .mobile-nav-item {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
}

/* ============================================
   iOS SAFE AREA SUPPORT
   ============================================ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-nav {
        padding-bottom: calc(var(--space-xs) + env(safe-area-inset-bottom));
    }
    
    .preview-toggle {
        bottom: calc(80px + var(--space-md) + env(safe-area-inset-bottom));
    }
    
    @media (max-width: 768px) {
        .main-content {
            padding-bottom: calc(80px + var(--space-md) + env(safe-area-inset-bottom));
        }
    }
}

/* ============================================
   DARK MODE SUPPORT (follows system preference)
   ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #1e293b;
        --gray-100: #1e293b;
        --gray-200: #334155;
        --gray-300: #475569;
        --gray-400: #64748b;
        --gray-500: #94a3b8;
        --gray-600: #cbd5e1;
        --gray-700: #e2e8f0;
        --gray-800: #f1f5f9;
        --gray-900: #f8fafc;
        --white: #0f172a;
    }
    
    body {
        background: #0f172a;
        color: var(--gray-800);
    }
    
    .form-panel,
    .output-panel,
    .modal-content {
        background: #1e293b;
    }
    
    .form-section {
        border-color: var(--gray-200);
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        background: var(--gray-100);
        border-color: var(--gray-300);
        color: var(--gray-800);
    }
    
    .mobile-nav {
        background: #1e293b;
        border-color: var(--gray-200);
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #0052cc;
        --accent: #d92929;
    }
    
    .btn {
        border-width: 2px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        border-width: 2px;
    }
}

