/* Base and Reset */
:root {
    --primary-color: #0f4c81;     /* Classic Blue */
    --secondary-color: #e8f0fe;   /* Light Blue */
    --accent-color: #ff6b6b;      /* Accent Red for highlights */
    --text-main: #333333;
    --text-muted: #6c757d;
    --bg-page: #f4f7f6;
    --bg-card: #ffffff;
    --border-color: #dee2e6;
    --input-bg: #f8f9fa;
    --success: #28a745;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    padding: 20px;
}

/* Utilities */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.pl-3 { padding-left: 1rem; }
.pr-3 { padding-right: 1rem; }
.fw-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Container & Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
}

.report-wrapper {
    background-color: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    padding: 40px;
    margin-bottom: 30px;
}

.row-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
.row-gap {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.align-center {
    align-items: center;
}

/* Actions Bar */
.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: #0b3963;
}

.btn-secondary {
    background-color: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}
.btn-secondary:hover {
    background-color: var(--secondary-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.remove-row-btn {
    color: var(--accent-color);
}

.remove-row-btn:hover {
    color: #dc3545;
}

/* Header */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 30px;
}

.header-logo {
    color: var(--primary-color);
}

.header-titles h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.header-titles p {
    color: var(--text-muted);
    font-size: 1rem;
}

.header-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Sections */
.report-section {
    margin-bottom: 35px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--secondary-color);
    padding: 10px 15px;
    border-radius: 8px;
}

.section-content {
    padding: 0 10px;
}

/* Form Controls */
input, select, textarea {
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 12px;
    background-color: var(--input-bg);
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
}

input[readonly] {
    background-color: transparent;
    border-color: transparent;
    font-weight: 600;
}

.inline-input {
    border: none;
    border-bottom: 1px dashed var(--text-muted);
    background: transparent;
    border-radius: 0;
    padding: 2px 5px;
}

.inline-input:focus {
    border-bottom: 1px solid var(--primary-color);
    background: var(--secondary-color);
}

.inline-input.short { width: 60px; text-align: center; }
.inline-input.medium { width: 150px; }
.inline-input.long { width: 300px; }

.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-main);
}
.form-group label.shrink {
    display: inline-block;
    margin-bottom: 0;
}

.form-control {
    display: block;
    width: 100%;
}

textarea {
    resize: vertical;
}

/* Tables */
.table-container {
    overflow-x: auto;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}
.report-table th, .report-table td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: right;
}
.report-table th {
    background-color: var(--input-bg);
    font-weight: 700;
}
.table-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 4px;
}
.table-input:focus {
    background-color: var(--secondary-color);
    border: none;
}
.select-input {
    width: 100%;
    border: none;
    background: transparent;
}

/* Radio & Checkboxes */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.radio-group.inline {
    display: inline-flex;
}
.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    gap: 5px;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    position: relative;
    padding-right: 30px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    user-select: none;
}
.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.checkmark {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}
.custom-checkbox:hover input ~ .checkmark {
    background-color: #e9ecef;
}
.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

/* Alert Boxes & Conditionals */
.alert-box {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 6px;
    padding: 15px;
    color: #856404;
}
.alert-box.light-blue {
    background-color: var(--secondary-color);
    border-color: #b8daff;
    color: #004085;
}
.details-box {
    background-color: var(--input-bg);
    border-right: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: 4px;
}

.conditional-fields {
    opacity: 0.5;
    pointer-events: none;
    transition: all 0.3s ease;
}
.conditional-fields.active {
    opacity: 1;
    pointer-events: auto;
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
}
.kpi-card {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.kpi-card span {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.kpi-input {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0;
}
.kpi-input:focus {
    background-color: var(--secondary-color);
    border-radius: 4px;
}

/* Confirmation Area */
.confirmation-section {
    background-color: var(--secondary-color);
    padding: 25px;
    border-radius: 8px;
    margin-top: 40px;
    border: 1px dashed var(--primary-color);
}
.large-checkbox .checkmark {
    height: 24px;
    width: 24px;
}
.large-checkbox .checkmark:after {
    left: 8px;
    top: 4px;
}
.large-checkbox {
    padding-right: 35px;
}
.confirm-text {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.signature-area {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
}
.signature-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 200px;
}
.signature-line span {
    font-weight: 700;
    color: var(--text-muted);
}
.signature-line .line {
    width: 100%;
    height: 2px;
    background-color: var(--text-main);
}

/* Print Styles */
@media print {
    body {
        background-color: white;
        padding: 0;
    }
    .noprint {
        display: none !important;
    }
    .report-wrapper {
        box-shadow: none;
        padding: 0;
    }
    input::placeholder, textarea::placeholder {
        color: transparent;
    }
    input, textarea, select {
        border-color: transparent !important;
        background-color: transparent !important;
    }
    .inline-input {
        border-bottom: 1px solid #000 !important;
        max-width: none !important;
    }
    .table-input {
        pointer-events: none;
    }
}

/* Responsive Design (Mobile & Tablet) */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    .report-wrapper {
        padding: 20px 15px;
    }
    .report-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .header-logo {
        margin-bottom: 10px;
    }
    .header-titles h1 {
        font-size: 1.5rem;
    }
    .header-meta {
        width: 100%;
        margin-top: 15px;
    }
    .header-meta .form-group.row-flex {
        justify-content: space-between;
    }
    .actions {
        flex-direction: column;
        width: 100%;
    }
    .actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Inputs */
    .inline-input {
        max-width: 100%;
    }
    .inline-input.long {
        width: 100%;
    }
    .table-input {
        min-width: 120px; /* Prevent overly squished table inputs */
    }
    
    /* Grids */
    .checkbox-grid, .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    /* Details box forms */
    .details-box .form-group.row-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .details-box .form-group.row-flex label {
        margin-bottom: 0;
    }
    .details-box .form-group.row-flex input {
        width: 100%;
        margin-right: 0;
    }
    
    /* Signatures */
    .signature-area {
        flex-direction: column;
        gap: 30px;
        align-items: center;
    }
    .signature-line {
        width: 100%;
        max-width: 250px;
    }
    
    /* Elements spacing */
    .section-title {
        font-size: 1.1rem;
        flex-wrap: wrap;
    }
}
