/* A5 — Component Polish (Forms, Tables, Toasts) */
/* Unified style system for all form controls, tables, and notifications */

/* ========================================
   FORM CONTROLS (Inputs, Selects, Textareas)
   ======================================== */

/* Base Input Styling */
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="date"],
select,
textarea {
    height: 44px; /* A5 spec: 44px minimum touch target */
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px; /* A5 spec: 12px radius */
    transition: all var(--transition);
    line-height: 1.5;
}

/* Textarea Override (height auto for multi-line) */
textarea.form-control {
    height: auto;
    min-height: 88px; /* 2x 44px */
    resize: vertical;
}

/* Focus States */
.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: var(--surface);
}

/* Hover States */
.form-control:hover:not(:focus),
.form-select:hover:not(:focus),
input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Disabled States */
.form-control:disabled,
.form-select:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.02);
}

/* Placeholder Styling */
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

/* Form Labels */
.form-label,
label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text);
}

/* Required Field Indicator */
.form-label:has(+ input[required])::after,
.form-label:has(+ select[required])::after,
.form-label:has(+ textarea[required])::after {
    content: " *";
    color: var(--danger);
}

/* Form Group Spacing */
.mb-3, .form-group {
    margin-bottom: 1.5rem;
}

/* Input Groups (with icons, buttons) */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group .form-control {
    flex: 1;
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.input-group .form-control:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
}

/* Validation States */
.form-control.is-invalid,
input.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus,
input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-control.is-valid,
input.is-valid {
    border-color: var(--success);
}

.form-control.is-valid:focus,
input.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.invalid-feedback {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--danger);
}

.valid-feedback {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--success);
}

/* Select Dropdown Arrow */
.form-select,
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a7b0c2' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* Checkbox & Radio Buttons */
.form-check-input {
    width: 20px;
    height: 20px;
    margin-top: 0.125rem;
    margin-right: 0.5rem;
    background-color: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Switch (Toggle) */
.form-switch .form-check-input {
    width: 44px;
    height: 24px;
    border-radius: 24px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: left center;
    background-size: contain;
}

.form-switch .form-check-input:checked {
    background-position: right center;
}


/* ========================================
   BUTTONS
   ======================================== */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition);
    min-height: 44px; /* Touch target */
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Button Variants */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-600);
    border-color: var(--primary-600);
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #000;
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: #000;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #000;
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
    color: #000;
}

/* Outline Buttons */
.btn-outline-primary {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-outline-dark {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

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

/* Button Sizes */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 52px;
}

/* Full Width Button */
.d-grid .btn {
    width: 100%;
}


/* ========================================
   TABLES
   ======================================== */

.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text);
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
}

/* Table Row Hover */
.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Striped Table */
.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.table-striped tbody tr:nth-of-type(odd):hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Bordered Table */
.table-bordered {
    border: 1px solid var(--border);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border);
}

/* Responsive Table */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table Actions (buttons in cells) */
.table td .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    min-height: 32px;
}


/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

/* Toast Container (Top-Right) */
.toast-container {
    position: fixed;
    top: 5rem; /* Below navbar */
    right: 2rem;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    pointer-events: none;
}

/* Individual Toast */
.toast {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition-slow);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%);
}

/* Toast Icon */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Toast Body */
.toast-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Toast Close Button */
.toast-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

/* Toast Variants */
.toast-success {
    border-left: 4px solid var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

.toast-info .toast-icon {
    color: var(--primary);
}

/* Mobile Toast Adjustments */
@media (max-width: 768px) {
    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: 100%;
    }
    
    .toast {
        min-width: 100%;
    }
}


/* ========================================
   CARDS
   ======================================== */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

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


/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    background: var(--primary);
    border-radius: 24px;
    white-space: nowrap;
}

.badge-success {
    background: var(--success);
    color: #000;
}

.badge-danger {
    background: var(--danger);
}

.badge-warning {
    background: var(--warning);
    color: #000;
}

.badge-primary {
    background: var(--primary);
}


/* ========================================
   ALERTS
   ======================================== */

.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.alert-dismissible {
    padding-right: 3rem;
    position: relative;
}

.alert .btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.alert .btn-close:hover {
    opacity: 1;
}
