/* Discraft — UI Components */

/* Toggle */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-active);
    border-radius: var(--radius-full);
    transition: var(--transition-base);
    border: 1px solid var(--border-default);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    bottom: 2px;
    left: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition-base);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: #fff;
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.color-preview {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-default);
    cursor: pointer;
    flex-shrink: 0;
}

input[type="color"] {
    width: 0;
    height: 0;
    padding: 0;
    border: none;
    visibility: hidden;
    position: absolute;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-default);
    gap: 0;
}

.tab {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    border: none;
    background: none;
    position: relative;
    transition: color var(--transition-fast);
}
.tab:hover {
    color: var(--text-secondary);
}
.tab.active {
    color: var(--text-accent);
}
.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: var(--radius-full) var(--radius-full) 0 0;
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-base);
}
.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp var(--transition-base);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.modal-header h3 {
    font-size: var(--text-lg);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--text-xl);
    cursor: pointer;
    padding: var(--space-1);
    line-height: 1;
}
.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    margin-bottom: var(--space-4);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: var(--space-6);
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    box-shadow: var(--shadow-md);
    animation: slideInRight var(--transition-base);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    max-width: 360px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.warning { border-color: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    font-size: var(--text-base);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-1);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: none;
    animation: fadeIn var(--transition-fast);
}

[dir="rtl"] .dropdown-menu {
    left: auto;
    right: 0;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: start;
}
.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-1) 0;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15em 0.5em;
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-full);
    background: var(--accent-subtle);
    color: var(--text-accent);
}

/* Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.checkbox-wrapper input[type="checkbox"] {
    width: 16px;
    height: 16px;
    appearance: none;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
}

/* Keyframes */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
