/* 
 * PHP Modernization - CSS Styling for Replaced HTML Elements
 * 
 * This file provides CSS classes to replace deprecated <font> tags
 * Include this in your main stylesheet or add to your template
 */

/* ============================================
   TABLE IMPROVEMENTS
   ============================================ */

/* Consistent row height and vertical centering */
.table > tbody > tr > td {
    vertical-align: middle;
}

/* Status badges inside tables */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-status-active   { background: #d4edda; color: #155724; }
.badge-status-inactive { background: #f8d7da; color: #721c24; }
.badge-status-pending  { background: #fff3cd; color: #856404; }
.badge-status-closed   { background: #e2e3e5; color: #383d41; }
.badge-status-open     { background: #cce5ff; color: #004085; }

/* Action buttons inside table rows */
.btn-table-action {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    min-height: 30px;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-table-action + .btn-table-action {
    margin-left: 4px;
}

/* Global box-header button polish — applies to ALL pages without touching PHP */
.box-header .btn.pull-right,
.box-header .btn-primary.pull-right {
    margin-left: 8px;
    margin-top: 2px;
    border-radius: 7px !important;
    font-weight: 600;
    font-size: 13px;
    padding: 5px 14px;
    min-width: 0 !important;
    width: auto !important;   /* override inline style='width:150px' */
}

/* keep gap when multiple pull-right buttons stack */
.box-header .btn.pull-right + .btn.pull-right {
    margin-right: 8px;
}

/* .nowrap utility for action button cells */
.nowrap { white-space: nowrap; }

/* Box header: title left, buttons right — flex layout */
.box-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.box-header-flex .box-title {
    flex: 1;
    min-width: 0;
}

.box-header-flex .box-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* DataTables filter bar */
.dataTables_wrapper .dataTables_filter {
    text-align: right;
}

.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label {
    font-weight: 600;
    color: #415264;
}

/* Processing indicator */
.dataTables_processing {
    border: 0 !important;
    background: rgba(255,255,255,0.9) !important;
    box-shadow: 0 4px 16px rgba(15,44,77,0.1) !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    color: #0f5ea8 !important;
}

/* ============================================
   SWEETALERT2 THEME OVERRIDE
   ============================================ */

.swal2-popup {
    border-radius: 14px !important;
    font-family: "Manrope", "Segoe UI", sans-serif !important;
}

.swal2-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #1f2937 !important;
}

.swal2-content, .swal2-html-container {
    font-size: 15px !important;
    color: #415264 !important;
}

.swal2-confirm {
    border-radius: 8px !important;
    font-weight: 700 !important;
}

.swal2-cancel {
    border-radius: 8px !important;
    font-weight: 600 !important;
}

/* Toast position tweak */
.swal2-container.swal2-top-end {
    padding-top: 70px;  /* clear fixed navbar */
}

/* ============================================
   FORM LAYOUT IMPROVEMENTS
   ============================================ */

.form-group label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    display: block;
}

.box-footer {
    background: #f8fafc;
    border-top: 1px solid #e7edf5;
    padding: 14px 18px;
}

.box-footer .btn {
    min-width: 110px;
    margin-right: 8px;
}

.box-footer .btn:last-child {
    margin-right: 0;
}

/* content-header breadcrumb-style row */
.content-header {
    padding: 20px 15px 12px;
}

.content-header > h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    color: #1e3a5f;
}

/* ============================================
   ERROR & VALIDATION MESSAGES
   ============================================ */

/* Error message styling (replaces <font color='red'>) */
.error-message {
    color: #d32f2f;
    font-weight: normal;
    display: inline;
}

/* Success message styling (replaces <font color='green'>) */
.success-message {
    color: #388e3c;
    font-weight: normal;
    display: inline;
}

/* Mandatory field indicator (replaces <font color='red'>*</font>) */
.mandatory-field {
    color: #d32f2f;
    font-weight: bold;
    margin-left: 2px;
}

/* Info/Informational message */
.info-message {
    color: #0288d1;
    font-weight: normal;
    display: inline;
}

/* Warning message */
.warning-message {
    color: #f57c00;
    font-weight: normal;
    display: inline;
}

/* ============================================
   ALERT BOXES (for JavaScript messages)
   ============================================ */

/* Success alert box (replaces <font color='green'><b>...</b></font>) */
.success-alert {
    background-color: #c8e6c9;
    border: 1px solid #388e3c;
    border-radius: 4px;
    color: #1b5e20;
    padding: 12px 16px;
    margin: 12px 0;
    display: block;
}

.success-alert b {
    font-weight: bold;
    color: #1b5e20;
}

/* Error alert box (replaces <font color='red'><b>...</b></font>) */
.error-alert {
    background-color: #ffcdd2;
    border: 1px solid #d32f2f;
    border-radius: 4px;
    color: #b71c1c;
    padding: 12px 16px;
    margin: 12px 0;
    display: block;
}

.error-alert b {
    font-weight: bold;
    color: #b71c1c;
}

/* Info alert box */
.info-alert {
    background-color: #b3e5fc;
    border: 1px solid #0288d1;
    border-radius: 4px;
    color: #01579b;
    padding: 12px 16px;
    margin: 12px 0;
    display: block;
}

.warning-alert {
    background-color: #ffe0b2;
    border: 1px solid #f57c00;
    border-radius: 4px;
    color: #e65100;
    padding: 12px 16px;
    margin: 12px 0;
    display: block;
}

/* ============================================
   FORM LABELS & VALIDATION
   ============================================ */

/* Required field label */
label.required::after {
    content: '*';
    color: #d32f2f;
    font-weight: bold;
    margin-left: 4px;
}

/* Form error styling */
.form-error {
    border-color: #d32f2f !important;
    background-color: #ffebee;
}

.form-error-text {
    color: #d32f2f;
    font-size: 0.875rem;
    margin-top: 4px;
    display: block;
}

/* Form success styling */
.form-success {
    border-color: #388e3c !important;
    background-color: #f1f8e9;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */

/* Status badge styles */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.875rem;
    font-weight: bold;
}

.status-active {
    background-color: #c8e6c9;
    color: #1b5e20;
}

.status-inactive {
    background-color: #ffcdd2;
    color: #b71c1c;
}

.status-pending {
    background-color: #fff9c4;
    color: #f57f17;
}

.status-submitted {
    background-color: #e1bee7;
    color: #4a148c;
}

/* ============================================
   TABLE CELL STYLING
   ============================================ */

/* Table cells with colored text */
td.text-red, td.error-text {
    color: #d32f2f;
    font-weight: bold;
}

td.text-green, td.success-text {
    color: #388e3c;
    font-weight: bold;
}

td.text-blue {
    color: #0288d1;
}

td.text-orange, td.warning-text {
    color: #f57c00;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide/Show utilities */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Text alignment */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

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

/* Font weight */
.font-bold {
    font-weight: bold;
}

.font-normal {
    font-weight: normal;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .success-alert,
    .error-alert,
    .info-alert,
    .warning-alert {
        padding: 10px 12px;
        font-size: 0.95rem;
    }
    
    .mandatory-field {
        margin-left: 1px;
    }
}

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

/* High contrast mode support */
@media (prefers-contrast: more) {
    .error-message {
        color: #b71c1c;
        text-decoration: underline;
    }
    
    .success-message {
        color: #1b5e20;
        text-decoration: underline;
    }
    
    .mandatory-field {
        border: 1px solid #d32f2f;
        padding: 1px 4px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .error-message {
        color: #e57373;
    }
    
    .success-message {
        color: #81c784;
    }
    
    .info-message {
        color: #64b5f6;
    }
    
    .warning-message {
        color: #ffb74d;
    }
    
    .success-alert {
        background-color: #2e7d32;
        border-color: #81c784;
        color: #c8e6c9;
    }
    
    .error-alert {
        background-color: #c62828;
        border-color: #e57373;
        color: #ffcdd2;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .error-alert,
    .success-alert,
    .info-alert,
    .warning-alert {
        border: 1px solid #333;
        page-break-inside: avoid;
    }
    
    .mandatory-field::after {
        content: '[Required]';
    }
}

/* ============================================
   GLOBAL APP UI ENHANCEMENTS
   ============================================ */

:root {
    --app-bg: #f5f7fb;
    --surface: #ffffff;
    --text-primary: #1f2937;
    --text-muted: #526072;
    --brand: #0f5ea8;
    --brand-strong: #08417a;
    --line-soft: #dbe4f0;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-soft: 0 8px 24px rgba(15, 44, 77, 0.08);
}

html,
body {
    font-family: "Manrope", "Segoe UI", "Helvetica Neue", sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, var(--app-bg) 100%);
    color: var(--text-primary);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.wrapper,
.content-wrapper {
    background: transparent;
}

.main-header .navbar {
    background: linear-gradient(110deg, var(--brand) 0%, var(--brand-strong) 100%);
    box-shadow: 0 2px 18px rgba(7, 30, 58, 0.16);
    border: 0;
}

.main-header .navbar-brand,
.main-header .navbar-nav > li > a,
.main-header .navbar-custom-menu .navbar-nav > li > a {
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.1px;
}

.main-header .navbar-brand {
    max-width: 72vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-header .navbar-nav > li > a:hover,
.main-header .navbar-nav > li > a:focus {
    background: rgba(255, 255, 255, 0.12);
}

.main-footer.app-footer {
    border-top: 1px solid var(--line-soft);
    background: #fbfdff;
    color: var(--text-muted);
}

.box {
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-soft);
    box-shadow: var(--shadow-soft);
}

.box-header.with-border {
    border-bottom: 1px solid var(--line-soft);
}

.btn {
    border-radius: var(--radius-md);
    min-height: 38px;
    font-weight: 600;
}

.form-control,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border-radius: var(--radius-md);
    min-height: 38px;
    border-color: #c9d6e8;
}

.form-control,
textarea,
select {
    max-width: 100%;
}

/* Keep long words and IDs from overflowing on smaller screens */
.table,
.table td,
.table th,
.box-body,
.content,
.form-group,
.control-label,
label,
p,
span,
a,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Better default table behavior on phone */
.table {
    background: var(--surface);
}

.app-quick-link > a {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.app-quick-link-label {
    display: inline-block;
}

.app-user-name {
    font-weight: 700;
}

.app-user-caret {
    margin-left: 4px;
}

.user-menu > .dropdown-menu {
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-soft);
    box-shadow: 0 12px 30px rgba(15, 44, 77, 0.16);
}

.user-menu .user-header {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
}

.user-menu .user-footer {
    padding: 12px;
}

.app-form-intro {
    color: var(--text-muted);
    margin-bottom: 14px;
}

.app-form-actions {
    padding-top: 4px;
}

@media (max-width: 991px) {
    .content-header > h1 {
        font-size: 24px;
        line-height: 1.25;
    }

    .box-header > .box-title {
        font-size: 18px;
        line-height: 1.35;
    }

    .main-footer .pull-right {
        float: none !important;
        display: block;
        margin-bottom: 6px;
    }

    .navbar-custom-menu {
        float: none;
    }

    .navbar-custom-menu > .navbar-nav {
        float: none;
    }
}

@media (max-width: 767px) {
    body {
        font-size: 14px;
    }

    .container,
    .content-wrapper .content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .main-header .navbar-brand {
        font-size: 16px;
        max-width: calc(100vw - 78px);
    }

    .main-header .navbar-toggle {
        border: 1px solid rgba(255, 255, 255, 0.45);
        margin-right: 10px;
        border-radius: 8px;
    }

    .main-header .navbar-collapse {
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        background: rgba(7, 40, 77, 0.95);
        padding-bottom: 8px;
    }

    .main-header .navbar-nav > li > a {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .app-quick-link > a {
        justify-content: flex-start;
    }

    .app-quick-link-label {
        font-size: 14px;
    }

    .main-header .navbar-custom-menu .navbar-nav > li > a {
        padding-top: 12px;
        padding-bottom: 12px;
    }

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

    .content-header > h1 {
        font-size: 20px;
    }

    .btn {
        min-height: 40px;
        padding: 8px 12px;
    }

    .table {
        font-size: 12px;
    }

    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 8px 6px;
        vertical-align: middle;
    }

    .box-footer .btn {
        width: 100%;
        margin: 0 0 8px 0;
    }

    .box-footer .btn:last-child {
        margin-bottom: 0;
    }

    .user-menu > .dropdown-menu {
        left: 12px;
        right: 12px;
    }

    .user-footer .pull-left,
    .user-footer .pull-right {
        float: none !important;
        width: 100%;
    }

    .user-footer .pull-left a,
    .user-footer .pull-right a {
        display: block;
        width: 100%;
        margin-bottom: 8px;
        text-align: center;
    }

    .user-footer .pull-right a {
        margin-bottom: 0;
    }

    .app-form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .content-header > h1 {
        font-size: 18px;
    }

    .control-label,
    .control-label-text,
    label {
        font-size: 13px;
    }

    .form-control,
    .select2-container--default .select2-selection--single {
        font-size: 14px;
    }

    .table {
        font-size: 11.5px;
    }

    .main-footer {
        font-size: 12px;
        line-height: 1.5;
    }
}
