/* ============================================
   COMPONENTS — Buttons, Cards, Forms, Tables,
   Badges, Alerts, Modals
   ============================================ */

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--control-height);
    padding: 0 var(--control-padding-x);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--font-size-base);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: var(--spacing-sm);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
    line-height: 1;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

/* Primary */
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 6px rgba(230, 0, 0, 0.2);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #cc0000 0%, #990000 100%);
    box-shadow: 0 6px 12px rgba(230, 0, 0, 0.3);
    color: white;
}

/* Secondary */
.btn-secondary {
    background-color: var(--color-bg-surface);
    color: var(--color-text-main);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg-surface-hover);
    border-color: var(--color-text-secondary);
    color: var(--color-text-main);
}

/* Outline */
.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.btn-outline:hover {
    border-color: var(--color-text-main);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text-main);
}

/* Outline Secondary (events view-all) */
.btn-outline-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    padding: 8px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.5px;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-outline-secondary:hover {
    background: rgba(230, 0, 0, 0.1);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 0 20px rgba(230, 0, 0, 0.3);
    transform: translateX(5px);
}

/* Danger */
.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background-color: #d32f2f;
    color: white;
}

/* Success */
.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    border: none;
    font-weight: 600;
}

.btn-success:hover {
    background: linear-gradient(135deg, #20c997 0%, #28a745 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
    color: #fff;
}

.btn-success i {
    margin-right: 5px;
}

/* Sizes */
.btn-sm {
    height: 32px;
    padding: 0 10px;
    font-size: var(--font-size-sm);
}

.btn-lg {
    height: 52px;
    padding: 0 24px;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

/* Icon Button (Square) */
.btn-icon-only {
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm.btn-icon-only {
    width: 32px;
    height: 32px;
}

/* Shadow Glow Variant */
.shadow-glow {
    box-shadow: var(--shadow-glow);
}

/* Grid Action Icon Buttons */
.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    transition: var(--transition-fast);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: var(--icon-size);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-main);
    border-color: var(--color-border);
}

.icon-btn.edit:hover {
    color: var(--color-warning);
    background: rgba(255, 171, 0, 0.1);
    border-color: rgba(255, 171, 0, 0.3);
}

.icon-btn.delete:hover {
    color: var(--color-danger);
    background: rgba(255, 23, 68, 0.1);
    border-color: rgba(255, 23, 68, 0.3);
}

.icon-btn.view:hover {
    color: var(--color-info);
    background: rgba(0, 176, 255, 0.1);
    border-color: rgba(0, 176, 255, 0.3);
}

/* ── Forms ── */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    height: var(--control-height);
    padding: 0 var(--control-padding-x);
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--color-text-main);
    background-color: var(--color-bg-surface);
    background-clip: padding-box;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

textarea.form-control {
    height: auto;
    min-height: var(--control-height);
    padding-top: 10px;
    padding-bottom: 10px;
}

.form-control:focus,
.form-select:focus {
    color: var(--color-text-main);
    background-color: var(--color-bg-surface-hover);
    border-color: var(--color-primary);
    outline: 0;
    box-shadow: 0 0 0 2px var(--color-primary-alpha);
}

.form-control::placeholder {
    color: var(--color-text-muted);
}

.form-control-sm,
.form-select-sm {
    height: 32px;
    padding: 0 8px;
    font-size: var(--font-size-sm);
}

input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}

input[type="date"] {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    transition: border-color 0.2s;
}

input[type="date"]:hover {
    border-color: rgba(255, 59, 48, 0.5);
}

input[type="date"]:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.2);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Input Group */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group>.form-control,
.input-group>.form-select,
.input-group>.input-group-text,
.input-group>.btn {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    border-radius: var(--radius-md);
}

.input-group>.input-group-text,
.input-group>.btn {
    width: auto;
    flex: 0 0 auto;
}

.input-group> :not(:first-child) {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group> :not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .form-control:focus,
.input-group .btn:focus {
    z-index: 3;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--color-text-main);
    text-align: center;
    white-space: nowrap;
    background-color: var(--color-bg-surface-hover);
    border: 1px solid var(--color-border);
}

/* ── Cards ── */
.card {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.card-glass {
    background: rgba(26, 26, 26, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header {
    padding: var(--spacing-lg);
    margin-bottom: 0;
    background-color: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    flex: 1 1 auto;
    padding: var(--spacing-lg);
}

/* Modal Body / Footer Standardized */
.modal-body {
    flex: 1 1 auto;
    padding: 2rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 10px;
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--color-border);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.card-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--color-border);
    background: rgba(0, 0, 0, 0.2);
}

.card-title {
    margin-bottom: 0;
    color: var(--color-text-main);
    font-size: 1.25rem;
    font-weight: 600;
}

/* Stat Card */
.card-stat {
    background: var(--gradient-surface);
    padding: var(--spacing-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card-stat:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-glow-red);
    border-color: var(--color-primary);
}

.card-stat .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    font-family: var(--font-heading);
    margin: 0.5rem 0;
    line-height: 1;
}

.card-stat .stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Vehicle Card */
.card-vehicle {
    background: var(--gradient-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: all var(--transition-normal);
    position: relative;
    margin-bottom: var(--spacing-lg);
}

.card-vehicle:hover {
    transform: translateY(-5px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow-red);
}

.card-vehicle-img {
    height: 200px;
    width: 100%;
    object-fit: cover;
    background-color: #000;
}

.card-vehicle-body {
    padding: var(--spacing-lg);
}

.card-vehicle-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-main);
    margin-bottom: var(--spacing-md);
    font-family: var(--font-heading);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--spacing-sm);
    text-transform: uppercase;
}

/* Stat Cards (vehicles/general) */
.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border-color: var(--color-primary);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--color-primary);
    text-shadow: 0 0 10px rgba(255, 59, 48, 0.3);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Tables ── */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    margin-bottom: var(--spacing-md);
}

.table {
    width: 100%;
    margin-bottom: 0;
    color: var(--color-text-secondary);
    vertical-align: top;
    border-color: var(--color-border);
    border-collapse: collapse;
}

.table> :not(caption)>*>* {
    padding: var(--spacing-md);
    background-color: transparent;
    border-bottom-width: 1px;
    box-shadow: inset 0 0 0 9999px transparent;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35em 0.8em;
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background-color: var(--color-primary-alpha);
    color: var(--color-primary-light);
    border: 1px solid var(--color-primary);
}

.badge-success {
    background-color: rgba(0, 230, 118, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(0, 230, 118, 0.3);
}

.badge-danger {
    background-color: rgba(255, 23, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(255, 23, 68, 0.3);
}

.badge-warning {
    background-color: rgba(255, 171, 0, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(255, 171, 0, 0.3);
}

.badge-info {
    background-color: rgba(0, 176, 255, 0.15);
    color: var(--color-info);
    border: 1px solid rgba(0, 176, 255, 0.3);
}

.badge-secondary {
    background-color: #333;
    color: #ccc;
    border: 1px solid #444;
}

.badge-dark {
    background: #000;
    color: #666;
    border: 1px solid #333;
}

/* Status Badges (Profile Cards) */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pending {
    background: rgba(255, 165, 0, 0.15);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.3);
}

.status-approved,
.status-paid {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.status-rejected,
.status-expired {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-active {
    background-color: #28a745;
    box-shadow: 0 0 5px #28a745;
}

.status-inactive {
    background-color: #6c757d;
}

/* ── Alerts ── */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.alert-error {
    background: rgba(255, 23, 68, 0.1);
    border: 1px solid rgba(255, 23, 68, 0.3);
    color: var(--color-danger);
}

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* Flex used for centering only when active */
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFadeIn 0.3s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a1a;
    background: linear-gradient(145deg, #222 0%, #0d0d0f 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 40px);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6);
    animation: modalSlideIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    color: var(--color-text-main);
}

.modal-xl {
    max-width: 1100px;
}

.modal-lg {
    max-width: 800px;
}

.modal-md {
    max-width: 600px;
}

.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.02);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    color: var(--color-text-main);
    letter-spacing: 0.5px;
}

.close {
    color: var(--color-text-muted);
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0;
}

.close:hover,
.close:focus {
    color: var(--color-primary);
    text-decoration: none;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Premium Close Button (Circuit Style) ── */
.btn-close-circuit {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    padding: 0;
}

.btn-close-circuit::before {
    content: '\f00d';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 14px;
}

.btn-close-circuit:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-alpha);
    transform: rotate(90deg);
}

.btn-close-circuit:active {
    transform: rotate(90deg) scale(0.9);
}

/* ── Payment Slip Display ── */
.slip-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: #000;
}

.slip-thumbnail:hover {
    transform: scale(1.1);
    border-color: var(--color-info);
    box-shadow: 0 0 10px rgba(0, 176, 255, 0.4);
}

.slip-preview-container {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    line-height: 0;
}

.slip-preview-container.xl {
    width: 80px;
    height: 100px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    margin-top: 10px;
}

.slip-preview-container.xl img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s;
}

.slip-preview-container.xl:hover img {
    transform: scale(1.05);
}

.slip-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--color-info);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 1px solid #000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}