/* public/css/p9_generator.css - CLEANED & MOBILE-RESPONSIVE */

.container { 
    padding: 1rem; 
    width: 100%; 
    max-width: 1400px; 
    margin: 0 auto; 
}

.p9-card { 
    background: white; 
    padding: 20px; 
    border-radius: 12px; 
    width: 100%; 
    color: #000; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.08); 
    border: 1px solid #e2e8f0; 
}

.p9-header-top {
    text-align: right;
    margin-bottom: 10px;
}

.appendix {
    font-weight: bold;
    font-size: 0.7rem;
    color: #666;
}

.p9-main-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #1a237e;
}

.p9-main-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #1a237e;
    letter-spacing: 1px;
}

.p9-main-header p {
    margin: 5px 0;
    font-size: 0.75rem;
    color: #37474f;
}

.p9-main-header .year-badge {
    background: #1a237e;
    color: white;
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-top: 8px;
}

.p9-header-table { 
    width: 100%; 
    margin-bottom: 15px; 
    font-size: 0.8rem; 
    border-collapse: collapse;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
}

.p9-header-table td, 
.p9-header-table th { 
    padding: 8px 6px; 
    border: 1px solid #e2e8f0;
}

.p9-header-table th { 
    font-weight: 700; 
    background: #f1f5f9;
    width: 18%;
    text-align: left;
}

/* Override borders for header cells - remove bottom borders except for Defined Contribution */
.p9-table thead tr:first-child th {
    border-bottom: none !important;
}

/* Keep bottom border only for the Defined Contribution header */
.p9-table thead tr:first-child th[colspan="3"] {
    border-bottom: 1px solid #cbd5e1 !important;
}

/* Ensure the second row sub-headers have bottom borders */
.p9-table thead tr:nth-child(2) th {
    border-bottom: 1px solid #cbd5e1;
    border-top: none;
}

.underline-box { 
    border-bottom: 1px solid #000; 
    font-weight: normal; 
    padding-left: 8px;
    background: white;
}

/* Table Styles */
.p9-table-container {
    overflow-x: auto;
    margin-top: 5px;
}

.p9-table { 
    width: 100%; 
    border-collapse: collapse; 
    table-layout: auto; 
    min-width: 1000px;
}

.p9-table th, 
.p9-table td { 
    border: 1px solid #cbd5e1; 
    padding: 6px 4px; 
    font-size: 0.7rem; 
    text-align: center; 
}

.p9-table th { 
    background: #f1f5f9; 
    font-weight: bold; 
    vertical-align: middle;
    color: #1a237e;
}

.p9-table .sub-header td {
    padding: 4px;
    background: #f8fafc;
}

.nested-header {
    display: flex;
    justify-content: space-between;
    gap: 2px;
}

.nested-header span {
    flex: 1;
    text-align: center;
    font-size: 0.6rem;
    padding: 2px;
    border-left: 1px solid #cbd5e1;
}

.nested-header span:first-child {
    border-left: none;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    gap: 8px;
    align-items: center;
    background: white;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.control-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #475569;
}

.control-group select {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.75rem;
    min-width: 200px;
    background: white;
    cursor: pointer;
}

.control-group select:focus {
    outline: none;
    border-color: var(--secondary);
}

.print-btn {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 6px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.print-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.kra-footer { 
    margin-top: 15px; 
    font-size: 0.65rem; 
}

.total-row {
    margin-bottom: 10px;
    font-weight: 800;
    border-top: 1px solid #cbd5e1;
    padding-top: 8px;
}

.total-row span {
    border-bottom: 3px double #000;
    padding: 0 15px;
    font-weight: bold;
}

.notes-grid { 
    display: grid; 
    grid-template-columns: 1.2fr 0.8fr; 
    gap: 15px; 
    margin-top: 8px; 
    text-align: justify; 
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }
    
    .p9-card {
        padding: 12px;
    }
    
    .p9-main-header h2 {
        font-size: 1rem;
    }
    
    .p9-main-header p {
        font-size: 0.65rem;
    }
    
    .p9-header-table td, 
    .p9-header-table th {
        padding: 6px 4px;
        font-size: 0.7rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        justify-content: space-between;
    }
    
    .control-group select {
        min-width: auto;
        flex: 1;
    }
    
    .print-btn {
        justify-content: center;
    }
    
    .notes-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .total-row {
        font-size: 0.7rem;
        text-align: center;
    }
    
    .total-row span {
        display: inline-block;
        margin: 5px 0;
    }
}

@media (max-width: 480px) {
    .p9-main-header h2 {
        font-size: 0.9rem;
    }
    
    .p9-header-table {
        font-size: 0.65rem;
    }
    
    .p9-table th, 
    .p9-table td {
        padding: 4px 2px;
        font-size: 0.6rem;
    }
    
    .nested-header span {
        font-size: 0.55rem;
    }
    
    .control-group label {
        font-size: 0.65rem;
    }
    
    .control-group select {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
    
    .print-btn {
        padding: 5px 16px;
        font-size: 0.7rem;
    }
}

/* Print Styles */
/* Print Styles - FIXED for complete printing */
@media print {
    /* Hide navigation elements */
    aside, header, .no-print, .controls, .nav-links, #logoutBtn, .menu-toggle, .header-badge, .user-info, .user-avatar {
        display: none !important;
    }
    
    body, html {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white;
    }
    
    main {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .p9-card {
        border: none !important;
        box-shadow: none !important;
        padding: 5px !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* Remove the min-width constraint for print */
    .p9-table {
        min-width: 100% !important;
        width: 100% !important;
        table-layout: auto !important;
    }
    
    .p9-table-container {
        overflow: visible !important;
        width: 100% !important;
    }
    
    /* Ensure all columns are visible */
    .p9-table th, 
    .p9-table td {
        border: 1px solid #000 !important;
        padding: 3px 2px !important;
        font-size: 7px !important;
        text-align: center !important;
        white-space: normal !important;
        word-break: keep-all !important;
    }
    
    /* Keep footer as two columns */
    .kra-footer {
        margin-top: 10px;
        font-size: 6px;
    }
    
    .notes-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-top: 5px;
    }
    
    .total-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        margin-bottom: 5px;
    }
    
    /* Force landscape orientation */
    @page {
        size: A4 landscape;
        margin: 3mm;
    }
    
    /* Ensure borders and backgrounds print */
    .p9-header-table th, 
    .p9-header-table td {
        border: 1px solid #000 !important;
    }
    
    .p9-table th {
        background: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .year-badge {
        background: #1a237e !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    body, div, span, p, td, th, li {
        color: #000 !important;
    }
}