/* base.css — Shared component library
   Loaded after variables.css. Provides standardized classes for
   containers, buttons, tables, tabs, modals, forms, empty states, and badges.
   Existing section CSS still loads after this, so nothing breaks immediately.
   Pages are migrated to use these classes over time. */

/* ==========================================================================
   1. CONTAINER
   ========================================================================== */

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    color: var(--text-main);
    box-sizing: border-box;
    background: var(--bg-container);
    backdrop-filter: var(--container-blur);
    -webkit-backdrop-filter: var(--container-blur);
    border: var(--container-border);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   2. PAGE HEADER
   ========================================================================== */

.page-header {
    display: flex;
    flex-direction: column;
    flex: none;
}

.page-header h2 {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    text-align: center;
    text-transform: uppercase;
}

/* ==========================================================================
   3. BUTTONS
   ========================================================================== */

/* Primary — gold background, white text */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-gold);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition), opacity var(--transition);
    white-space: nowrap;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    filter: none;
}

/* Secondary — outlined */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* Danger — red background */
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition);
    white-space: nowrap;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

/* Submit — green background */
.btn-submit {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--success);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition);
    white-space: nowrap;
}

.btn-submit:hover {
    filter: brightness(1.1);
}

/* Cancel — grey background */
.btn-cancel {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: #6c757d;
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition);
    white-space: nowrap;
}

.btn-cancel:hover {
    filter: brightness(1.1);
}

/* Next — alias for primary */
.btn-next {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-gold);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition);
    white-space: nowrap;
}

.btn-next:hover {
    filter: brightness(1.1);
}

/* Back — grey */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: #6c757d;
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition);
    white-space: nowrap;
}

.btn-back:hover {
    filter: brightness(1.1);
}

/* Finalize — green */
.btn-finalize {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--success);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition);
    white-space: nowrap;
}

.btn-finalize:hover {
    filter: brightness(1.1);
}

/* Icon button — for table action columns */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon img {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--border-light);
}

.btn-icon:hover img {
    opacity: 1;
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-edit:hover { background-color: var(--info-light); }
.btn-delete:hover { background-color: var(--danger-light); }
.btn-info:hover { background-color: var(--warning-light); }

/* ==========================================================================
   3b. FORM INPUTS / SELECTS / DATE PICKERS
   ========================================================================== */

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    color: var(--text-main);
    background: var(--bg-input);
    transition: border-color var(--transition);
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-gold);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder {
    color: var(--text-light);
}

label.form-label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-main);
}

/* ==========================================================================
   4. DATA TABLE / LIST ROWS
   ========================================================================== */

/* Table header row */
.data-table-header {
    display: flex;
    flex-direction: row;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--font-xs);
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
}

/* Data row */
.data-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
    cursor: pointer;
    min-width: 0;
}

.data-row:hover {
    background-color: var(--bg-hover);
}

.data-row:last-child {
    border-bottom: none;
}

/* Table cell */
.data-cell {
    flex: 1;
    display: flex;
    align-items: center;
    padding: var(--space-sm);
    min-width: 0;
    box-sizing: border-box;
}

.data-cell p {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    min-width: 0;
}

/* Cell modifiers */
.data-cell--wrap {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.data-cell--wrap p {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.data-cell--stacked {
    flex-direction: column;
    align-items: flex-start;
}

/* Cell name variant (for first/primary column) */
.data-cell--name p {
    text-align: start;
}

/* Actions column */
.data-cell--actions {
    flex: 0 0 100px;
    min-width: 100px;
}

/* ==========================================================================
   5. TABS
   ========================================================================== */

/* Tab navigation bar */
.tabs-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
}

/* Individual tab button */
.tab-btn {
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font-family);
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary-gold);
    border-bottom-color: var(--primary-gold);
}

/* Tab content pane */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Tab toggle (pill-style, for list pages) */
.tab-toggle {
    display: flex;
    gap: 0;
}

.tab-toggle button {
    border-radius: 0;
    border: 1px solid var(--primary-gold);
    background: var(--white);
    color: var(--text-main);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: var(--font-sm);
    transition: background var(--transition), color var(--transition);
}

.tab-toggle button:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.tab-toggle button:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.tab-toggle button.active {
    background: var(--primary-gold);
    color: var(--white);
}

/* ==========================================================================
   6. MODALS (enhances modal.css)
   ========================================================================== */

/* Close button — standard across all modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: 90%;
    position: relative;
    box-shadow: var(--shadow-lg);
    max-height: 90%;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    background: none;
    border: none;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

/* ==========================================================================
   7. FORMS
   ========================================================================== */

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-main);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-sm) 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-base);
    color: var(--text-main);
    box-sizing: border-box;
    transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-gold);
}

.form-input::placeholder {
    color: var(--text-light);
}

/* ==========================================================================
   8. EMPTY STATES
   ========================================================================== */

.empty-state {
    padding: var(--space-2xl);
    text-align: center;
}

.empty-state h3 {
    color: var(--text-muted);
    margin-top: 0;
    font-size: var(--font-lg);
    font-weight: 600;
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: var(--space-md);
}

/* ==========================================================================
   9. BADGES / PILLS
   ========================================================================== */

.badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-pill);
    font-size: var(--font-xs);
    font-weight: 700;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-info    { background: var(--info-light);    color: #1e40af; }
.badge-muted   { background: #e5e7eb; color: #6b7280; }

/* ==========================================================================
   10. PAGINATION
   ========================================================================== */

.pagination {
    display: flex;
    flex-direction: row;
    padding: var(--space-sm) var(--space-md);
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    border-top: 1px solid var(--border-light);
}

.pagination button {
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text-main);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-sm);
    transition: background var(--transition);
}

.pagination button:hover {
    background: var(--border-light);
}

.pagination button.active {
    background: var(--primary-gold);
    color: var(--white);
    border-color: var(--primary-gold);
}

.pagination span {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* ==========================================================================
   11. UTILITY CLASSES
   ========================================================================== */

.action-group {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    justify-content: flex-start;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* ==========================================================================
   12. RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .page-header h2 {
        font-size: var(--font-xl);
    }

    .modal-content {
        width: 95%;
        padding: var(--space-md);
    }

    .tabs-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================================================
   13. UTILITY LAYOUT HELPERS
   Replaces common inline styles in PHP templates
   ========================================================================== */

.flex-row {
    display: flex;
    flex-direction: row;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-1 {
    flex: 1;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-sm { font-size: var(--font-sm); }
.font-base { font-size: var(--font-base); }
.font-lg { font-size: var(--font-lg); }

.text-muted { color: var(--text-muted); }
.text-dark { color: var(--text-dark); }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

.border-b { border-bottom: 1px solid var(--border-light); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Search input used across multiple pages */
.search-input {
    padding: var(--space-sm) 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    color: var(--text-main);
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-gold);
}

/* Filter select used across multiple pages */
.filter-select {
    padding: var(--space-sm) 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-sm);
    color: var(--text-main);
    background: var(--white);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-gold);
}
