/**
 * Units of Competency Display Styles
 * 
 * @package RTOGrow
 * @since 2.4.3
 */

/* Container */
.rto-units-display {
    margin: 2rem 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Header */
.rto-units-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
}

.rto-units-title {
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.rto-units-icon {
    font-size: 1.75rem;
}

/* Summary Badges */
.rto-units-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.rto-units-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    font-size: 0.875rem;
    color: #fff;
    backdrop-filter: blur(4px);
}

.rto-units-badge strong {
    font-weight: 700;
    font-size: 1rem;
}

.rto-units-total {
    background: rgba(255, 255, 255, 0.25);
}

.rto-units-core {
    background: rgba(34, 197, 94, 0.3);
}

.rto-units-elective {
    background: rgba(168, 85, 247, 0.3);
}

.rto-units-hours {
    background: rgba(251, 191, 36, 0.3);
}

/* Table Wrapper */
.rto-units-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table */
.rto-units-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.rto-units-table thead {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.rto-units-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rto-units-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.rto-units-table tbody tr:hover {
    background: #f8fafc;
}

.rto-units-table tbody tr:last-child td {
    border-bottom: none;
}

/* Column Widths */
.rto-col-code {
    width: 160px;
    min-width: 140px;
}

.rto-col-hours {
    width: 100px;
    text-align: center;
}

.rto-col-title {
    min-width: 200px;
}

/* Unit Code */
.rto-unit-code {
    display: inline-block;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    color: #2563eb;
    background: #eff6ff;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #dbeafe;
}

/* Unit Title */
.rto-unit-title {
    display: block;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.4;
}

/* Unit Description */
.rto-unit-description {
    display: block;
    margin: 0.5rem 0 0 0;
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.5;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid #e2e8f0;
}

.rto-unit-field {
    display: inline-block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Unit Hours */
.rto-unit-hours {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 0.375rem 0.75rem;
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
    border-radius: 6px;
    font-size: 0.875rem;
}

.rto-unit-hours-na {
    color: #94a3b8;
}

/* Table Footer - Total */
.rto-units-table tfoot {
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
}

.rto-units-total-row td {
    padding: 1rem 1.5rem;
    border-bottom: none;
}

.rto-total-label {
    text-align: right;
    font-weight: 600;
    color: #475569;
}

.rto-total-hours {
    text-align: center;
    font-size: 1.125rem;
    color: #1e293b;
}

.rto-total-hours strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1f2937;
    border-radius: 8px;
}

/* Footer Disclaimer */
.rto-units-footer {
    padding: 1rem 2rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.rto-units-disclaimer {
    margin: 0;
    color: #64748b;
    font-size: 0.8125rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .rto-units-display {
        margin: 1rem 0;
        border-radius: 8px;
        max-width: 100%;
        overflow: hidden;
    }
    
    .rto-units-header {
        padding: 1rem;
    }
    
    .rto-units-title {
        font-size: 1.125rem;
        gap: 0.5rem;
    }
    
    .rto-units-icon {
        font-size: 1.25rem;
    }
    
    .rto-units-summary {
        gap: 0.5rem;
    }
    
    .rto-units-badge {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }
    
    .rto-units-badge strong {
        font-size: 0.8125rem;
    }
    
    .rto-units-table-wrapper {
        overflow-x: hidden;
    }
    
    /* Stack table on mobile - card layout */
    .rto-units-table,
    .rto-units-table thead,
    .rto-units-table tbody,
    .rto-units-table tfoot,
    .rto-units-table th,
    .rto-units-table td,
    .rto-units-table tr {
        display: block;
        width: 100%;
    }
    
    .rto-units-table thead {
        display: none;
    }
    
    .rto-units-table tbody tr {
        margin: 0 1rem 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        overflow: hidden;
        background: #fff;
    }
    
    .rto-units-table td {
        padding: 0.75rem 1rem;
        text-align: left;
        border-bottom: 1px solid #f1f5f9;
        display: block;
        width: 100%;
        box-sizing: border-box;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .rto-units-table td:last-child {
        border-bottom: none;
    }
    
    .rto-units-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: #64748b;
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.375rem;
    }
    
    .rto-col-code,
    .rto-col-title,
    .rto-col-hours {
        width: 100%;
        min-width: 0;
    }
    
    .rto-col-hours {
        text-align: left;
    }
    
    .rto-unit-code {
        font-size: 0.8125rem;
        padding: 0.25rem 0.5rem;
    }
    
    .rto-unit-title {
        font-size: 0.9375rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.4;
    }
    
    .rto-unit-description {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
    }
    
    .rto-units-table tfoot {
        padding: 1rem;
    }
    
    .rto-units-table tfoot tr {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 1rem;
    }
    
    .rto-units-table tfoot td {
        border: none;
        padding: 0.5rem 0;
    }
    
    .rto-total-label {
        text-align: left;
    }
    
    .rto-total-hours strong {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .rto-units-footer {
        padding: 0.75rem 1rem;
    }
    
    .rto-units-disclaimer {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .rto-units-display {
        margin: 0.75rem 0;
        border-radius: 6px;
    }
    
    .rto-units-header {
        padding: 0.875rem;
    }
    
    .rto-units-title {
        font-size: 1rem;
    }
    
    .rto-units-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.6875rem;
    }
    
    .rto-units-table tbody tr {
        margin: 0 0.875rem 0.75rem;
    }
    
    .rto-units-table td {
        padding: 0.625rem 0.875rem;
    }
    
    .rto-unit-title {
        font-size: 0.875rem;
    }
}

/* Force text wrap on all screen sizes */
.rto-unit-title,
.rto-unit-description,
.rto-col-title {
    word-break: break-word;
    hyphens: auto;
}

/* Critical Mobile Fix - ONLY for units table */
@media screen and (max-width: 768px) {
    .rto-units-display {
        width: 100% !important;
    }
    
    .rto-units-table-wrapper {
        width: 100% !important;
    }
    
    .rto-units-table {
        display: block !important;
        width: 100% !important;
    }
    
    .rto-units-table tbody {
        display: block !important;
        width: 100% !important;
    }
    
    .rto-units-table tbody tr {
        display: block !important;
        width: 100% !important;
    }
    
    .rto-units-table tbody td {
        display: block !important;
        width: auto !important;
        box-sizing: border-box !important;
    }
    
    .rto-units-table tbody td.rto-col-code,
    .rto-units-table tbody td.rto-col-title,
    .rto-units-table tbody td.rto-col-hours {
        width: auto !important;
        min-width: 0 !important;
    }
    
    .rto-units-table span.rto-unit-title,
    .rto-units-table .rto-unit-title {
        display: block !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }
    
    .rto-units-table p.rto-unit-description,
    .rto-units-table .rto-unit-description {
        display: block !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }
}

/* Print Styles */
@media print {
    .rto-units-display {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .rto-units-header {
        background: #1e3a5f !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .rto-units-table {
        font-size: 10pt;
    }
}
