/**
 * GraceWaves Enhanced Forms Stylesheet
 * Beautiful, modern form components with excellent UX
 */

/* ========================================
   CSS Variables / Theme
   ======================================== */
:root {
    --gw-primary: #10b981;
    --gw-primary-light: #34d399;
    --gw-primary-dark: #059669;
    --gw-primary-subtle: rgba(16, 185, 129, 0.1);
    --gw-danger: #ef4444;
    --gw-warning: #f59e0b;
    --gw-info: #3b82f6;
    --gw-border-color: rgba(0, 0, 0, 0.1);
    --gw-input-bg: #ffffff;
    --gw-input-border: #e5e7eb;
    --gw-input-focus-border: var(--gw-primary);
    --gw-input-focus-shadow: rgba(16, 185, 129, 0.25);
    --gw-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --gw-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --gw-radius: 12px;
    --gw-radius-lg: 16px;
    --gw-radius-sm: 8px;
}

/* Dark theme support */
[data-theme="dark"] {
    --gw-border-color: rgba(255, 255, 255, 0.1);
    --gw-input-bg: rgba(255, 255, 255, 0.05);
    --gw-input-border: rgba(255, 255, 255, 0.15);
    --gw-card-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ========================================
   Card Component
   ======================================== */
.gw-card {
    background: var(--gw-input-bg);
    border-radius: var(--gw-radius-lg);
    box-shadow: var(--gw-card-shadow);
    transition: var(--gw-transition);
    border: 1px solid var(--gw-border-color);
}

.gw-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.gw-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gw-border-color);
}

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

.gw-card-icon {
    background: var(--gw-primary-subtle);
    transition: var(--gw-transition);
}

.gw-card:hover .gw-card-icon {
    transform: scale(1.05);
}

.gw-collapse-icon {
    transition: transform 0.3s ease;
}

[aria-expanded="false"] .gw-collapse-icon {
    transform: rotate(-90deg);
}

/* ========================================
   Input Fields
   ======================================== */
.gw-input,
.gw-select,
.gw-textarea {
    background: var(--gw-input-bg);
    border: 2px solid var(--gw-input-border);
    border-radius: var(--gw-radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: inherit;
    transition: var(--gw-transition);
}

.gw-input:hover,
.gw-select:hover,
.gw-textarea:hover {
    border-color: rgba(16, 185, 129, 0.4);
}

.gw-input:focus,
.gw-select:focus,
.gw-textarea:focus {
    border-color: var(--gw-input-focus-border);
    box-shadow: 0 0 0 4px var(--gw-input-focus-shadow);
    outline: none;
    background: var(--gw-input-bg);
}

.form-control-lg.gw-input {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    border-radius: var(--gw-radius);
}

.gw-input::placeholder,
.gw-textarea::placeholder {
    color: rgba(107, 114, 128, 0.7);
}

/* Input with icon */
.input-group .gw-input {
    border-radius: 0 var(--gw-radius-sm) var(--gw-radius-sm) 0;
}

.input-group .input-group-text {
    background: var(--gw-input-bg);
    border: 2px solid var(--gw-input-border);
    border-radius: var(--gw-radius-sm) 0 0 var(--gw-radius-sm);
    padding: 0.75rem 1rem;
    transition: var(--gw-transition);
}

.input-group:focus-within .input-group-text {
    border-color: var(--gw-input-focus-border);
}

.input-group:focus-within .gw-input {
    border-left-color: var(--gw-input-focus-border);
}

/* ========================================
   Select Fields
   ======================================== */
.gw-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
    cursor: pointer;
}

.gw-select option {
    padding: 0.5rem;
}

/* ========================================
   Textarea
   ======================================== */
.gw-textarea {
    resize: vertical;
    min-height: 100px;
}

.gw-textarea:focus {
    min-height: 120px;
}

/* ========================================
   Toggle/Switch
   ======================================== */
.gw-switch .gw-switch-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
    background-color: #d1d5db;
    border: none;
    border-radius: 1.5rem;
    transition: var(--gw-transition);
}

.gw-switch .gw-switch-input:checked {
    background-color: var(--gw-primary);
}

.gw-switch .gw-switch-input:focus {
    box-shadow: 0 0 0 4px var(--gw-input-focus-shadow);
}

.gw-switch-primary .gw-switch-input:checked {
    background-color: var(--gw-primary);
}

.gw-switch-success .gw-switch-input:checked {
    background-color: #22c55e;
}

.gw-switch-danger .gw-switch-input:checked {
    background-color: #ef4444;
}

.gw-switch-warning .gw-switch-input:checked {
    background-color: #f59e0b;
}

.gw-switch-info .gw-switch-input:checked {
    background-color: #3b82f6;
}

/* ========================================
   Image Upload Component
   ======================================== */
.gw-image-upload-container {
    cursor: pointer;
}

.gw-image-preview-wrapper {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 3px solid transparent;
    transition: var(--gw-transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.gw-image-preview-wrapper:hover {
    border-color: var(--gw-primary);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.2);
}

.gw-image-preview {
    transition: transform 0.4s ease, filter 0.3s ease;
}

.gw-image-preview-wrapper:hover .gw-image-preview {
    transform: scale(1.03);
}

.gw-image-preview-wrapper:hover .gw-image-overlay {
    opacity: 1 !important;
}

.gw-image-overlay button {
    transform: translateY(10px);
    opacity: 0;
    transition: var(--gw-transition);
}

.gw-image-preview-wrapper:hover .gw-image-overlay button {
    transform: translateY(0);
    opacity: 1;
}

.gw-image-preview-wrapper:hover .gw-image-overlay button:nth-child(2) {
    transition-delay: 0.05s;
}

.gw-upload-empty {
    cursor: pointer;
    transition: var(--gw-transition);
    background: rgba(16, 185, 129, 0.02) !important;
    border: 2px dashed rgba(16, 185, 129, 0.3) !important;
}

.gw-upload-empty:hover {
    background: rgba(16, 185, 129, 0.08) !important;
    border-color: var(--gw-primary) !important;
}

.gw-upload-empty i {
    transition: var(--gw-transition);
}

.gw-upload-empty:hover i {
    transform: translateY(-3px);
    color: var(--gw-primary) !important;
}

/* ========================================
   Form Labels
   ======================================== */
.form-label {
    font-weight: 600;
    color: inherit;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.form-label .text-danger {
    font-weight: 700;
}

/* ========================================
   Form Hints & Feedback
   ======================================== */
.form-text {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.35rem;
}

.invalid-feedback {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 0.35rem;
}

/* ========================================
   Buttons - Enhanced
   ======================================== */
.btn {
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: var(--gw-radius-sm);
    transition: var(--gw-transition);
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--gw-primary) 0%, var(--gw-primary-dark) 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--gw-primary-light) 0%, var(--gw-primary) 100%);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: var(--gw-radius);
}

.btn-outline-secondary {
    border: 2px solid var(--gw-border-color);
    color: inherit;
}

.btn-outline-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.2);
}

/* ========================================
   Alert Improvements
   ======================================== */
.alert {
    border: none;
    border-radius: var(--gw-radius);
    padding: 1rem 1.25rem;
    border-left: 4px solid transparent;
}

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

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--gw-primary);
    color: var(--gw-primary-dark);
}

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

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--gw-info);
    color: #1d4ed8;
}

/* ========================================
   Form Row Spacing
   ======================================== */
.row.g-3 > [class*="col-"] > .mb-3:last-child {
    margin-bottom: 0 !important;
}

/* ========================================
   Page Header Enhancement
   ======================================== */
.gw-page-header {
    padding: 1.5rem 0 2rem;
    margin-bottom: 1rem;
}

.gw-page-header h1 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.gw-page-header .breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.gw-page-header .breadcrumb-item + .breadcrumb-item::before {
    content: "→";
    color: #9ca3af;
}

/* ========================================
   Animations
   ======================================== */
@keyframes gw-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.gw-shake {
    animation: gw-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes gw-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.gw-pulse {
    animation: gw-pulse 1s infinite;
}

@keyframes gw-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gw-fade-in {
    animation: gw-fadeIn 0.4s ease both;
}

/* ========================================
   Drag & Drop States
   ======================================== */
.gw-drag-over {
    border-color: var(--gw-primary) !important;
    background: rgba(16, 185, 129, 0.1) !important;
}

.gw-drag-over * {
    pointer-events: none;
}

/* ========================================
   Cursor Helpers
   ======================================== */
.cursor-pointer {
    cursor: pointer;
}

.cursor-grab {
    cursor: grab;
}

.cursor-grabbing {
    cursor: grabbing;
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 767px) {
    .gw-card-body {
        padding: 1rem;
    }
    
    .btn-lg {
        width: 100%;
        padding: 1rem 1.5rem;
    }
    
    .gw-image-preview-wrapper {
        width: 150px !important;
        height: 150px !important;
    }
}

/* ========================================
   Loading States
   ======================================== */
.gw-loading {
    position: relative;
    pointer-events: none;
}

.gw-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* ========================================
   Success State
   ======================================== */
.gw-success {
    border-color: var(--gw-primary) !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2) !important;
}
