/**
 * Reusable Component Library
 * World-Class Design System Components
 * 
 * Usage:
 * - Import this file after design-system.css
 * - Use component classes for consistent UI
 */

/* ============================================
   FORM COMPONENTS
   ============================================ */

/* Form Group - Container for form fields */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Form Label */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.87);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.form-label.required::after {
    content: " *";
    color: #ef4444;
}

/* Form Input - Text, Email, Tel, Number, etc. */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(0, 0, 0, 0.87);
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: 4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:hover {
    border-color: rgba(0, 0, 0, 0.5);
}

.form-input:focus {
    outline: none;
    border-color: #6b1026;
    box-shadow: 0 0 0 3px rgba(107, 16, 38, 0.12);
}

.form-input:disabled {
    background-color: #f5f3f0;
    color: rgba(0, 0, 0, 0.38);
    cursor: not-allowed;
}

.form-input::placeholder {
    color: rgba(0, 0, 0, 0.6);
    opacity: 1;
}

/* Form Input Error State */
.form-input.error,
.form-input.is-invalid {
    border-color: #ef4444;
}

.form-input.error:focus,
.form-input.is-invalid:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Form Input Success State */
.form-input.success,
.form-input.is-valid {
    border-color: #22c55e;
}

.form-input.success:focus,
.form-input.is-valid:focus {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Form Select */
.form-select {
    width: 100%;
    padding: 0.625rem 2rem 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(0, 0, 0, 0.87);
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b6860' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.5em 1.5em;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: 4px;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-select:hover {
    border-color: rgba(0, 0, 0, 0.5);
}

.form-select:focus {
    outline: none;
    border-color: #6b1026;
    box-shadow: 0 0 0 3px rgba(107, 16, 38, 0.12);
}

.form-select:disabled {
    background-color: #f5f3f0;
    color: rgba(0, 0, 0, 0.38);
    cursor: not-allowed;
}

/* Form Textarea */
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(0, 0, 0, 0.87);
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: 4px;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.form-textarea:hover {
    border-color: rgba(0, 0, 0, 0.5);
}

.form-textarea:focus {
    outline: none;
    border-color: #6b1026;
    box-shadow: 0 0 0 3px rgba(107, 16, 38, 0.12);
}

.form-textarea:disabled {
    background-color: #f5f3f0;
    color: rgba(0, 0, 0, 0.38);
    cursor: not-allowed;
}

/* Form Checkbox */
.form-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(0, 0, 0, 0.23);
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
}

.form-checkbox:checked {
    background-color: #6b1026;
    border-color: #6b1026;
}

.form-checkbox:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: bold;
}

.form-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 16, 38, 0.15);
}

.form-checkbox:disabled {
    background-color: #f5f3f0;
    border-color: rgba(0, 0, 0, 0.23);
    cursor: not-allowed;
}

/* Form Radio */
.form-radio {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(0, 0, 0, 0.23);
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
}

.form-radio:checked {
    border-color: #6b1026;
}

.form-radio:checked::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0.625rem;
    height: 0.625rem;
    background-color: #6b1026;
    border-radius: 50%;
}

.form-radio:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 16, 38, 0.15);
}

.form-radio:disabled {
    background-color: #f5f3f0;
    border-color: rgba(0, 0, 0, 0.23);
    cursor: not-allowed;
}

/* Form Help Text */
.form-help {
    display: block;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.6);
    margin-top: 0.25rem;
}

/* Form Error Message */
.form-error {
    display: block;
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* Form Success Message */
.form-success {
    display: block;
    font-size: 0.75rem;
    color: #22c55e;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ============================================
   BUTTON COMPONENTS
   ============================================ */

/* Base Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 16, 38, 0.2);
}

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

/* Button Sizes */
.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
}

.btn-md {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* Button Variants (colors defined in standard-colors.css) */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info,
.btn-outline-primary,
.btn-outline-secondary,
.btn-ghost {
    /* Base styles already defined in .btn */
}

/* Button Full Width */
.btn-block {
    width: 100%;
    display: flex;
}

/* Button Icon */
.btn-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.btn-icon-sm {
    width: 0.875rem;
    height: 0.875rem;
}

.btn-icon-lg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================
   CARD COMPONENTS
   ============================================ */

/* Base Card */
.card {
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Card Header */
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    font-weight: 600;
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.87);
}

/* Card Body */
.card-body {
    padding: 1.25rem;
}

.card-body-sm {
    padding: 0.875rem;
}

.card-body-lg {
    padding: 1.5rem;
}

/* Card Footer */
.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    background-color: rgba(0, 0, 0, 0.02);
}

/* Card Variants */
.card-elevated {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-elevated:hover {
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.card-flat {
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.card-outlined {
    box-shadow: none;
    border: 2px solid rgba(0, 0, 0, 0.12);
}

/* ============================================
   MODAL COMPONENTS
   ============================================ */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Modal Container */
.modal {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    animation: modal-slide-up 0.3s ease;
    overflow: hidden;
}

@keyframes modal-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

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

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

/* Modal Header */
.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.87);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.87);
}

/* Modal Body */
.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ============================================
   BADGE COMPONENTS
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-sm {
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
}

.badge-lg {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-error {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-info {
    background-color: #f5e8eb;
    color: #6b1026;
}

.badge-primary {
    background-color: #f5edd8;
    color: #4a0d1a;
}

/* ============================================
   ALERT COMPONENTS
   ============================================ */

.alert {
    padding: 1rem 1.25rem;
    border-radius: 4px;
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.alert-message {
    font-size: 0.875rem;
    line-height: 1.5;
}

.alert-success {
    background-color: #d1fae5;
    border-left-color: #22c55e;
    color: #065f46;
}

.alert-error {
    background-color: #fee2e2;
    border-left-color: #ef4444;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    border-left-color: #f59e0b;
    color: #92400e;
}

.alert-info {
    background-color: #f5e8eb;
    border-left-color: #6b1026;
    color: #4a0d1a;
}

/* ============================================
   EMPTY STATE COMPONENT
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    color: rgba(0, 0, 0, 0.38);
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.87);
    margin-bottom: 0.5rem;
}

.empty-state-message {
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.6);
    margin-bottom: 1.5rem;
}

.empty-state-action {
    margin-top: 1rem;
}

/* ============================================
   SKELETON LOADER COMPONENT
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        #f5f3f0 0%,
        #e8e6e1 50%,
        #f5f3f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 60%;
}

.skeleton-title {
    height: 1.5rem;
    width: 70%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-button {
    height: 2.5rem;
    width: 8rem;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 640px) {
    .modal {
        max-width: 95vw;
        margin: 0.5rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-block-mobile {
        width: 100%;
    }
}
