/*
 * ============================================
 * COMPONENTS.CSS - REUSABLE UI COMPONENTS
 * Modern, accessible component library
 * ============================================
 */

/* ============================================
   BUTTONS
   ============================================ */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
    border-radius: var(--radius-xl);
}

.btn-xl {
    padding: var(--space-5) var(--space-10);
    font-size: var(--text-lg);
    border-radius: var(--radius-xl);
}

/* Primary Button */
.btn-primary {
    background: var(--gradient-primary);
    color: var(--white);
    box-shadow: var(--shadow-md), 0 0 20px rgba(14, 165, 233, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(14, 165, 233, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background: var(--gradient-dark);
    color: var(--white);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Accent Button */
.btn-accent {
    background: var(--gradient-sunset);
    color: var(--white);
    box-shadow: var(--shadow-md), 0 0 20px rgba(244, 63, 94, 0.2);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(244, 63, 94, 0.35);
}

/* Outline Button */
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
}

.btn-outline-white {
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn-outline-white:hover {
    background: var(--white);
    color: var(--secondary);
    border-color: var(--white);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

/* Glass Button */
.btn-glass {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

/* Icon Button */
.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn-icon.btn-sm {
    width: 36px;
    height: 36px;
}

.btn-icon.btn-lg {
    width: 52px;
    height: 52px;
}

/* Full Width */
.btn-block {
    width: 100%;
}

/* Button with Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    transform: scale(0);
    opacity: 0;
    transition: transform 0.5s, opacity 0.3s;
}

.btn-ripple:active::after {
    transform: scale(2.5);
    opacity: 1;
    transition: 0s;
}

/* ============================================
   CARDS
   ============================================ */

/* Base Card */
.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

/* Card Image */
.card-img {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/10;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-img img {
    transform: scale(1.1);
}

/* Card Image Overlay */
.card-img-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--space-5);
    color: var(--white);
}

/* Card Body */
.card-body {
    padding: var(--space-6);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: var(--space-3);
}

.card-text {
    color: var(--gray-500);
    margin-bottom: var(--space-4);
    line-height: 1.6;
}

/* Card Badge */
.card-badge {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    padding: var(--space-2) var(--space-4);
    background: var(--white);
    color: var(--primary);
    font-size: var(--text-xs);
    font-weight: 700;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
}

/* Card Price Tag */
.card-price {
    position: absolute;
    bottom: var(--space-4);
    right: var(--space-4);
    padding: var(--space-2) var(--space-5);
    background: var(--gradient-primary);
    color: var(--white);
    font-size: var(--text-lg);
    font-weight: 700;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
}

/* Glass Card */
.card-glass {
    background: var(--glass-bg-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Horizontal Card */
.card-horizontal {
    display: flex;
    flex-direction: row;
}

.card-horizontal .card-img {
    width: 40%;
    aspect-ratio: auto;
}

.card-horizontal .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 640px) {
    .card-horizontal {
        flex-direction: column;
    }

    .card-horizontal .card-img {
        width: 100%;
        aspect-ratio: 16/9;
    }
}

/* ============================================
   FORMS
   ============================================ */

/* Form Group */
.form-group {
    margin-bottom: var(--space-5);
}

/* Form Label */
.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--secondary);
}

.form-label i {
    color: var(--primary);
    margin-right: var(--space-2);
}

/* Form Input */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-4);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--gray-800);
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

.form-input::placeholder {
    color: var(--gray-400);
}

/* Form Input Sizes */
.form-input-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.form-input-lg {
    padding: var(--space-5);
    font-size: var(--text-lg);
}

/* Form Select */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    background-size: 20px;
    padding-right: var(--space-12);
    cursor: pointer;
}

/* Form Textarea */
.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* Floating Label */
.form-floating {
    position: relative;
}

.form-floating .form-input {
    padding-top: var(--space-6);
    padding-bottom: var(--space-2);
}

.form-floating .form-label {
    position: absolute;
    top: 50%;
    left: var(--space-4);
    transform: translateY(-50%);
    transition: all var(--transition-fast);
    pointer-events: none;
    color: var(--gray-400);
    margin: 0;
}

.form-floating .form-input:focus~.form-label,
.form-floating .form-input:not(:placeholder-shown)~.form-label {
    top: var(--space-2);
    transform: translateY(0);
    font-size: var(--text-xs);
    color: var(--primary);
}

/* Input with Icon */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-input {
    padding-left: var(--space-12);
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.input-icon-wrapper .form-input:focus~.input-icon {
    color: var(--primary);
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.form-check-input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check-label {
    font-size: var(--text-sm);
    color: var(--gray-600);
    cursor: pointer;
}

/* ============================================
   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);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
}

.alert-icon {
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.alert-content h4 {
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
}

.alert-content p {
    font-size: var(--text-sm);
    margin: 0;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--info);
    color: var(--info);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

/* ============================================
   AVATARS
   ============================================ */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: var(--text-sm);
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: var(--text-xl);
}

.avatar-xl {
    width: 96px;
    height: 96px;
    font-size: var(--text-3xl);
}

/* Avatar Group */
.avatar-group {
    display: flex;
}

.avatar-group .avatar {
    margin-left: -12px;
    border: 3px solid var(--white);
}

.avatar-group .avatar:first-child {
    margin-left: 0;
}

/* ============================================
   DIVIDERS
   ============================================ */
.divider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    color: var(--gray-400);
    font-size: var(--text-sm);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

/* ============================================
   TAGS
   ============================================ */
.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.tag:hover {
    background: var(--gray-200);
}

.tag-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.tag-primary:hover {
    background: var(--primary);
    color: var(--white);
}

/* ============================================
   TOOLTIPS (CSS Only)
   ============================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: var(--space-2) var(--space-3);
    background: var(--secondary);
    color: var(--white);
    font-size: var(--text-xs);
    white-space: nowrap;
    border-radius: var(--radius-md);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-10px);
}

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.progress-sm {
    height: 4px;
}

.progress-lg {
    height: 12px;
}

/* ============================================
   MOBILE TOUCH IMPROVEMENTS
   ============================================ */
@media (max-width: 768px) {
    .btn {
        min-height: 48px;
        padding: var(--space-4) var(--space-6);
    }

    .form-input,
    .form-select,
    .form-textarea {
        min-height: 48px;
        font-size: 16px;
        /* Prevents iOS zoom */
    }

    .btn-icon {
        width: 48px;
        height: 48px;
    }
}