/* Shared Components - Buttons, Spinners, Toasts, Modals */
/* DARK MODE OPTIMIZED */

/* ============================================================================
   BUTTONS
   ============================================================================ */

/* Base button styles - apply to all buttons */
.btn {
    /* Layout & Spacing */
    padding: 0.75rem 1.5rem;

    /* Visual */
    border: 2px solid transparent;
    border-radius: 8px;
    background: transparent;

    /* Typography */
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-primary);

    /* Interaction */
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:active:not(:disabled) {
    transform: translateY(0) !important;
}

/* Button Variants - Role-based */
.btn-primary {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-light);
    border-color: var(--primary-blue);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Legacy alias for btn-danger */
.btn-remove {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.btn-remove:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Button Size Modifiers */
.btn--small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn--large {
    padding: 1rem 2rem;
    font-size: 1.05rem;
}

/* Button State Modifiers */
.btn.active {
    border-color: var(--primary-blue);
    background: rgba(59, 130, 246, 0.1);
}

/* Menu Button - Specialized icon-based button */
.menu-button {
    /* Layout */
    padding: 8px 12px;

    /* Visual */
    background: none;
    border: none;
    border-radius: var(--border-radius);

    /* Typography */
    font-size: 1.5rem;
    color: var(--text-primary);
    line-height: 1;

    /* Interaction */
    cursor: pointer;
    transition: all var(--transition-fast);
}

.menu-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Menu Button Size Variants */
.menu-button--medium {
    font-size: 1.25rem;
}

.menu-button--small {
    font-size: 1rem;
    padding: 6px 10px;
}

/* Menu Button Color Variants */
.menu-button--blue {
    background: var(--primary-blue);
    color: white;
}

.menu-button--blue:hover {
    background: var(--primary-blue-dark);
}

/* ============================================================================
   LOADING SPINNER
   ============================================================================ */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 30px;
    height: 30px;
    border-width: 3px;
}

.spinner-large {
    width: 50px;
    height: 50px;
    border-width: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading States */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    color: var(--text-secondary);
}

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    color: #ef4444;
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-light);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    border-left: 4px solid var(--primary-blue);
    max-width: 400px;
    animation: slide-in 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-fade-out {
    animation: fade-out 0.3s ease-out forwards;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fade-out {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================================================
   MODALS & OVERLAYS
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-container {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 100%;
    border: 1px solid var(--border-color);
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header-section {
    text-align: center;
    margin-bottom: 30px;
}

.modal-logo {
    font-size: 3em;
    margin-bottom: 15px;
}

.modal-title {
    font-size: 1.75em;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.modal-subtitle {
    font-size: 1em;
    color: var(--text-secondary);
    margin: 0;
}

/* Modal Close Button - Specialized circular button */
.modal-close-btn {
    /* Position */
    position: absolute;
    top: 20px;
    right: 20px;

    /* Layout */
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Visual */
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;

    /* Typography */
    font-size: 24px;
    color: var(--text-secondary);

    /* Interaction */
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.modal-form {
    margin-top: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

/* Modal Button - Base for modal action buttons */
.modal-btn {
    /* Layout */
    flex: 1;
    padding: 14px 24px;

    /* Visual */
    border: 2px solid transparent;
    border-radius: 12px;

    /* Typography */
    font-size: 1em;
    font-weight: 600;

    /* Interaction */
    cursor: pointer;
    transition: all var(--transition-fast);
}

/* Modal Button Variants */
.modal-btn-primary {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.modal-btn-primary:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.modal-btn-secondary {
    background: var(--bg-light);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-blue);
}

/* ============================================================================
   FORM GROUPS
   ============================================================================ */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--input-text);
    font-size: 1em;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: var(--input-bg-focus);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-help {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    line-height: 1.4;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Standalone Form Classes - for use outside .form-group */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-label {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 14px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1em;
    color: var(--input-text);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    background: var(--input-bg-focus);
    border-color: var(--primary-blue);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-select {
    cursor: pointer;
}

/* Action Icon - Used in cards and buttons */
.action-icon {
    font-size: 1.3em;
}

/* Toggle Labels - Checkbox with text label */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.toggle-label span {
    font-size: 0.9em;
    color: var(--text-primary);
    font-weight: 500;
}

/* Checkbox Labels - Styled checkbox rows */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    cursor: pointer;
    user-select: none;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ============================================================================
   COLLAPSIBLE SECTIONS
   ============================================================================ */

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
    transition: opacity 0.2s;
    user-select: none;
}

.collapsible-header:hover {
    opacity: 0.8;
}

.collapse-arrow {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.collapsible-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* ============================================================================
   EMPTY STATES
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--bg-light);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.empty-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* ============================================================================
   STATUS INDICATORS
   ============================================================================ */

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.status-indicator:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--primary-blue-light);
}

.status-icon {
    font-size: 18px;
    line-height: 1;
}

.status-text {
    font-size: 14px;
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    .toast {
        max-width: none;
    }

    .modal-container {
        padding: 30px 20px;
        margin: 10px;
    }

    .modal-logo {
        font-size: 2.5em;
    }

    .modal-title {
        font-size: 1.5em;
    }

    .modal-subtitle {
        font-size: 0.9em;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    /* Adjust menu buttons for smaller screens */
    .menu-button {
        font-size: 1.25rem;
        padding: 6px 10px;
    }

    /* Adjust standard buttons for smaller screens */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }

    .status-indicator {
        padding: 6px 10px;
    }

    .status-icon {
        font-size: 16px;
    }
}
