/**
 * TuerSmart v2.3 - Components
 * ============================
 * Reusable UI Components
 * 
 * @author IBKuehne
 * @date 2025-11-24 05:05:00 UTC
 */

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    user-select: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Button Variants */
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-success:hover {
    background: #16a34a;
}

.btn-error {
    background: var(--error);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-error:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-warning:hover {
    background: #d97706;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--background);
    border-color: var(--primary);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
}

.btn-block {
    width: 100%;
}

/* Button with Icon */
.btn-icon {
    padding: var(--space-3);
    aspect-ratio: 1;
}

/* Button States */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   FORMS
   ======================================== */

.form-group {
    margin-bottom: var(--space-5);
}

label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
}

label.required::after {
    content: ' *';
    color: var(--error);
}

/* Text Inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text);
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input:disabled,
textarea:disabled,
select:disabled {
    background: var(--background);
    color: var(--text-muted);
    cursor: not-allowed;
}

input.error,
textarea.error,
select.error {
    border-color: var(--error);
}

input.error:focus,
textarea.error:focus,
select.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Input with Icon */
.input-group {
    position: relative;
}

.input-group input {
    padding-right: var(--space-12);
}

.input-group-icon {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-group-btn {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
}

/* Checkbox & Radio */
.checkbox,
.radio {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.checkbox input,
.radio input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox label,
.radio label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}

/* Form Hints */
.form-hint {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.form-error {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--error);
}

.form-success {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--success);
}

/* ========================================
   CARDS
   ======================================== */

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    margin: 0;
    font-size: var(--text-xl);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border);
    background: var(--background);
}

/* Card Variants */
.card-hover {
    transition: all var(--transition-base);
    cursor: pointer;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-gradient {
    background: var(--primary-gradient);
    color: white;
}

.card-gradient .card-header,
.card-gradient .card-footer {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ========================================
   ALERTS
   ======================================== */

.alert {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.alert-success {
    background: var(--success-light);
    border-color: var(--success);
    color: #065f46;
}

.alert-error {
    background: var(--error-light);
    border-color: var(--error);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background: var(--info-light);
    border-color: var(--info);
    color: #1e40af;
}

.alert strong {
    display: block;
    margin-bottom: var(--space-1);
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-error {
    background: var(--error);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: white;
}

.badge-secondary {
    background: var(--background);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Status Badges */
.badge-online {
    background: var(--status-online);
    color: white;
}

.badge-offline {
    background: var(--status-offline);
    color: white;
}

.badge-warning-status {
    background: var(--status-warning);
    color: white;
}

/* ========================================
   TABLES
   ======================================== */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--background);
    border-bottom: 2px solid var(--border);
}

th {
    padding: var(--space-4) var(--space-5);
    text-align: left;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
}

tr:hover {
    background: var(--background);
}

tr:last-child td {
    border-bottom: none;
}

/* ========================================
   MODALS
   ======================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
    padding: var(--space-4);
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--text-2xl);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--background);
    color: var(--text);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ========================================
   LOADING STATES
   ======================================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

/* ========================================
   NAVIGATION
   ======================================== */

.nav {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4);
    background: white;
    border-bottom: 1px solid var(--border);
}

.nav-item {
    padding: var(--space-3) var(--space-4);
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-item:hover {
    background: var(--background);
    color: var(--primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

/* ========================================
   DIVIDER
   ======================================== */

.divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-6) 0;
}

.divider-vertical {
    width: 1px;
    background: var(--border);
    margin: 0 var(--space-4);
}

/* ========================================
   ANIMATIONS
   ======================================== */

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glow {
    animation: glow 2s ease-out;
}

@keyframes glow {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    100% {
        box-shadow: 0 0 0 20px rgba(102, 126, 234, 0);
    }
}

/* ========================================
   UTILITIES
   ======================================== */

.pointer {
    cursor: pointer;
}

.no-select {
    user-select: none;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}