/**
 * Zorbalama Frontend - Component Styles
 * 
 * Reusable UI components with Light/Dark mode support.
 */

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    min-width: 300px;
    max-width: 400px;
    background: var(--color-surface);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition-base);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
}

.toast-message {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
}

/* Toast variants */
.toast-success {
    border-left: 4px solid var(--color-success-500);
}

.toast-success .toast-icon {
    color: var(--color-success-500);
}

.toast-error {
    border-left: 4px solid var(--color-danger-500);
}

.toast-error .toast-icon {
    color: var(--color-danger-500);
}

.toast-warning {
    border-left: 4px solid var(--color-warning-500);
}

.toast-warning .toast-icon {
    color: var(--color-warning-500);
}

.toast-info {
    border-left: 4px solid var(--color-primary);
}

.toast-info .toast-icon {
    color: var(--color-primary);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .toast-container {
        top: var(--space-3);
        right: var(--space-3);
        left: var(--space-3);
    }

    .toast {
        min-width: auto;
        max-width: none;
    }
}


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

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--transition-base);
    overflow-y: auto;
}

.modal-overlay.show {
    opacity: 1;
}

.modal {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: var(--color-surface);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform var(--transition-base);
    margin: auto;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    border-bottom: var(--border-width) solid var(--color-border);
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    margin: 0;
    color: var(--color-text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-md);
    color: var(--color-text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

.modal-body {
    padding: var(--space-6);
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-6);
    border-top: var(--border-width) solid var(--color-border);
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-overlay {
        padding: var(--space-4);
    }

    .modal {
        max-width: 100%;
        margin: 0;
    }

    .modal-body {
        max-height: calc(100vh - 250px);
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }
}


/* ========================================
   LOADING STATES
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.loading-overlay.show {
    opacity: 1;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-message {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    margin: 0;
}

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading .spinner-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Skeleton loader */
.skeleton-loader {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg,
            var(--color-surface) 25%,
            var(--color-surface-hover) 50%,
            var(--color-surface) 75%);
    background-size: 200% 100%;
    border-radius: var(--border-radius-sm);
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-line:nth-child(2) {
    width: 80%;
}

.skeleton-line:last-child {
    width: 60%;
}

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

    100% {
        background-position: -200% 0;
    }
}


/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Scrollbar styling (webkit browsers) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border-light);
    border-radius: var(--border-radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-neutral-600);
}

/* Focus visible outline */
*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Hide visually but keep accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}


/* ========================================
   ACTION BUTTONS & TOGGLE
   ======================================== */

.action-buttons {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    align-items: center;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-icon svg {
    display: block;
}

.btn-icon.btn-edit:hover {
    background: rgba(100, 116, 139, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-icon.btn-delete:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: var(--color-danger-500);
    color: var(--color-danger-500);
}

.btn-icon:active {
    transform: translateY(0);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-neutral-700);
    border-radius: 26px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.slider {
    background: var(--color-success-500);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(22px);
}

.toggle-switch input:focus+.slider {
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.2);
}

.toggle-switch:hover .slider {
    box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.15);
}

/* Responsive */
@media (max-width: 768px) {
    .action-buttons {
        gap: var(--space-1);
    }

    .btn-icon {
        width: 28px;
        height: 28px;
    }
}


/* ========================================
   PAGE LAYOUT COMPONENTS
   ======================================== */

.page-header {
    margin-bottom: var(--space-8);
}

.page-title {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
}

.page-subtitle {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    margin: 0;
}

.content-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

/* Error/Empty State */
.error-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-secondary);
}

.error-state h3 {
    margin: 1rem 0 0.5rem;
    color: var(--color-text-primary);
}


/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .action-buttons {
        gap: var(--space-1);
    }

    .btn-icon {
        width: 28px;
        height: 28px;
    }

    .content-card {
        padding: var(--space-4);
    }
}


/* ========================================
   LANGUAGE SELECTOR
   ======================================== */

.language-selector {
    position: relative;
    display: inline-block;
}

.language-selector-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.language-selector-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
}

.language-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 18px;
}

.language-flag svg {
    display: block;
    width: 100%;
    height: 100%;
}

.language-code {
    font-family: var(--font-family);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.05em;
}

.language-dropdown-icon {
    font-size: 10px;
    opacity: 0.6;
    transition: transform var(--transition-fast);
}

.language-selector-btn:hover .language-dropdown-icon {
    opacity: 1;
}

/* Dropdown menu */
.language-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
}

.language-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.language-option:first-child {
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
}

.language-option:last-child {
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
}

.language-option:hover {
    background: var(--color-surface-hover);
}

.language-option.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
}

.language-option .language-name {
    flex: 1;
    font-family: var(--font-family);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .language-selector-btn {
        padding: var(--space-2);
    }

    .language-code {
        display: none;
    }

    .language-dropdown {
        left: 0;
        right: auto;
    }
}

