/* ============================================
   HACKATHON FORM BUILDER & TAB SYSTEM
   Styles for Event Create/Edit form builder
   and ManageApplications tab navigation
   ============================================ */

/* ============================================
   1. FORM BUILDER (Event Create / Event Edit)
   ============================================ */

/* Main container - shown when EventType=Hackathon */
#hackathonFormBuilder {
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    margin-top: 1.5rem;
}

/* Gradient header strip */
#hackathonFormBuilder .hfb-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.25rem 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

#hackathonFormBuilder .hfb-header-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

#hackathonFormBuilder .hfb-header-title i {
    font-size: 1.25rem;
}

#hackathonFormBuilder .hfb-header-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}

#hackathonFormBuilder .hfb-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---- Field Card ---- */
.hfb-field-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.hfb-field-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.hfb-field-card.dragging {
    opacity: 0.5;
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
}

/* Field header: drag handle | label | type badge | actions */
.hfb-field-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: default;
}

/* Drag handle - 6-dot grid icon */
.hfb-drag-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 20px;
    height: 28px;
    cursor: grab;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s ease;
}

.hfb-drag-handle:active {
    cursor: grabbing;
}

.hfb-field-card:hover .hfb-drag-handle {
    opacity: 0.7;
}

.hfb-drag-handle i {
    font-size: 1rem;
    color: #64748b;
}

/* Field label text */
.hfb-field-label {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a202c;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hfb-field-label .hfb-required-star {
    color: #ef4444;
    margin-left: 2px;
    font-weight: 700;
}

/* Type badge - pill with color per type */
.hfb-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Type badge color variants */
.hfb-type-badge.type-text {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.hfb-type-badge.type-email {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.hfb-type-badge.type-phone {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.hfb-type-badge.type-radio {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.hfb-type-badge.type-checkbox {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.hfb-type-badge.type-textarea {
    background: rgba(20, 184, 166, 0.1);
    color: #14b8a6;
}

.hfb-type-badge.type-number {
    background: rgba(236, 72, 153, 0.1);
    color: #ec4899;
}

.hfb-type-badge.type-url {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

/* Field header actions */
.hfb-field-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Expand / collapse toggle */
.hfb-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.hfb-expand-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Delete button - ghost style, red on hover */
.hfb-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.hfb-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ---- Field Body (expandable area) ---- */
.hfb-field-body {
    padding: 0 1.25rem 1.25rem;
    display: none;
    border-top: 1px solid #e2e8f0;
}

.hfb-field-body.expanded {
    display: block;
    animation: hfbSlideDown 0.3s ease;
}

@keyframes hfbSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Field body form groups */
.hfb-field-body .hfb-form-group {
    margin-top: 1rem;
}

.hfb-field-body .hfb-form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}

.hfb-field-body .hfb-form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #1a202c;
    background: white;
    transition: all 0.3s ease;
}

.hfb-field-body .hfb-form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.hfb-field-body .hfb-form-input::placeholder {
    color: #94a3b8;
}

/* Options editor - textarea for Radio/Checkbox options */
.hfb-options-editor {
    margin-top: 1rem;
    display: none;
}

.hfb-options-editor.visible {
    display: block;
    animation: hfbSlideDown 0.25s ease;
}

.hfb-options-editor textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #1a202c;
    background: white;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
    transition: all 0.3s ease;
}

.hfb-options-editor textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.hfb-options-editor textarea::placeholder {
    color: #94a3b8;
}

.hfb-options-editor .hfb-options-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.375rem;
    font-style: italic;
}

/* Help text input */
.hfb-helptext-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #1a202c;
    background: white;
    transition: all 0.3s ease;
}

.hfb-helptext-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.hfb-helptext-input::placeholder {
    color: #94a3b8;
}

/* ---- Required Toggle (iOS style) ---- */
.hfb-required-toggle {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    user-select: none;
}

.hfb-required-toggle input[type="checkbox"] {
    display: none;
}

.hfb-toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.hfb-toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}

.hfb-required-toggle input[type="checkbox"]:checked + .hfb-toggle-track {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.hfb-required-toggle input[type="checkbox"]:checked + .hfb-toggle-track::after {
    transform: translateX(20px);
}

.hfb-toggle-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    transition: color 0.3s ease;
}

.hfb-required-toggle input[type="checkbox"]:checked ~ .hfb-toggle-label {
    color: #334155;
}

/* ---- Add Field Card ---- */
.hfb-add-field {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
}

.hfb-add-field:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.04);
}

.hfb-add-field i {
    font-size: 1.25rem;
    color: #94a3b8;
    transition: color 0.3s ease;
}

.hfb-add-field:hover i {
    color: #667eea;
}

.hfb-add-field span {
    font-size: 0.95rem;
    font-weight: 600;
    color: #94a3b8;
    transition: color 0.3s ease;
}

.hfb-add-field:hover span {
    color: #667eea;
}

/* ---- Default Fields Notice ---- */
.hfb-default-notice {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
}

.hfb-default-notice i {
    font-size: 1rem;
}

/* ---- Add Field Dropdown / Selector ---- */
.hfb-add-dropdown {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: none;
    margin-top: 0.5rem;
}

.hfb-add-dropdown.visible {
    display: block;
    animation: hfbSlideDown 0.25s ease;
}

.hfb-add-dropdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.hfb-add-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    transition: all 0.2s ease;
}

.hfb-add-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #667eea;
}

.hfb-add-option i {
    font-size: 1rem;
}

/* ---- Field Label Inline Edit ---- */
.hfb-label-input {
    flex: 1;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a202c;
    padding: 0.25rem 0.5rem;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s ease;
    min-width: 0;
}

.hfb-label-input:focus {
    outline: none;
    border-bottom-color: #667eea;
}

.hfb-label-input::placeholder {
    color: #94a3b8;
}

/* ---- Empty State ---- */
.hfb-empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: #94a3b8;
}

.hfb-empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.hfb-empty-state p {
    font-size: 0.95rem;
    margin: 0;
    color: #64748b;
}


/* ============================================
   2. TAB SYSTEM (ManageApplications)
   ============================================ */

/* Tab bar container */
.app-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.app-tabs::-webkit-scrollbar {
    display: none;
}

/* Individual tab button */
.app-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: #64748b;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    position: relative;
}

.app-tab:hover {
    color: #1e293b;
}

/* Active tab */
.app-tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
}

/* Tab icon */
.app-tab i {
    font-size: 1rem;
}

/* Tab badge - mini pill number */
.app-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.5rem;
    line-height: 1;
}

/* Badge variant: pending - pulsing animation */
.app-tab-badge.pending {
    animation: hfbPulse 2s infinite;
}

@keyframes hfbPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* Badge variant: muted/zero */
.app-tab-badge.muted {
    background: #e2e8f0;
    color: #64748b;
}

/* Tab content container */
.app-tab-content {
    display: none;
}

.app-tab-content.active {
    display: block;
    animation: hfbFadeIn 0.35s ease;
}

@keyframes hfbFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ============================================
   3. RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    /* Form builder */
    #hackathonFormBuilder .hfb-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem 1.25rem;
    }

    #hackathonFormBuilder .hfb-body {
        padding: 1rem;
    }

    .hfb-field-header {
        padding: 0.875rem 1rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .hfb-field-label {
        font-size: 0.9rem;
    }

    .hfb-type-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.625rem;
    }

    .hfb-field-body {
        padding: 0 1rem 1rem;
    }

    .hfb-add-dropdown-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tabs */
    .app-tab {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .app-tab-badge {
        min-width: 20px;
        height: 20px;
        font-size: 0.7rem;
        padding: 0 5px;
    }
}

@media (max-width: 576px) {
    #hackathonFormBuilder .hfb-header-title {
        font-size: 1rem;
    }

    .hfb-field-header {
        padding: 0.75rem;
    }

    .hfb-drag-handle {
        display: none;
    }

    .hfb-field-body {
        padding: 0 0.75rem 0.75rem;
    }

    .hfb-field-body .hfb-form-input,
    .hfb-options-editor textarea,
    .hfb-helptext-input {
        font-size: 0.85rem;
        padding: 0.625rem 0.875rem;
    }

    .hfb-add-field {
        padding: 1rem;
    }

    .hfb-add-dropdown-grid {
        grid-template-columns: 1fr;
    }

    /* Tabs stacked on very small screens */
    .app-tabs {
        flex-wrap: nowrap;
    }

    .app-tab {
        padding: 0.625rem 0.875rem;
        font-size: 0.8rem;
    }

    .app-tab i {
        display: none;
    }
}
