/* ==========================================================================
   Reusable UI Components: Buttons, Cards, Modals, Badges, Tables, Inputs
   ========================================================================== */

/* Brand Logo */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 22px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.brand-text {
    background: linear-gradient(135deg, var(--text-main) 60%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    transition: all var(--transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
    transform: translateY(-1px);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-light);
}

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

.btn-outline:hover:not(:disabled) {
    background: var(--primary-light);
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: var(--radius-lg);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

/* Metric / Stat Card */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.stat-growth {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 6px;
}

.growth-up { color: var(--success); }
.growth-down { color: var(--danger); }

/* Badges & Status Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

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

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

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

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

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

/* Forms & Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--primary);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
    height: auto;
    padding: 12px 16px;
    min-height: 100px;
    resize: vertical;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    text-align: left;
}

.table th {
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-input);
}

.table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.modal-backdrop.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--bg-input);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
