/**
 * AFSNote - Components
 * Buttons, dropdowns, forms, toasts, and other reusable UI
 */

/* ================================
   MENU BAR - Fixed below header
   ================================ */
.menu-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 8px 12px;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    z-index: 99;
}

.menu-bar::-webkit-scrollbar {
    display: none;
}

.menu-button {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.menu-button:hover {
    background: var(--divider);
    border-color: var(--border);
}

.menu-button:active {
    transform: scale(0.97);
}

.menu-button svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.menu-button span {
    display: inline;
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.icon-button:hover {
    background: var(--divider);
    color: var(--text);
}

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

.dropdown-content {
    display: none;
    position: fixed;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    min-width: 200px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top left;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    overflow: hidden;
}

.dropdown-content.dropdown-right {
    left: auto;
    right: 0;
    transform-origin: top right;
}

.dropdown-content.show {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.dropdown-label {
    padding: 10px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    transition: background var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--divider);
}

.dropdown-item:active {
    background: var(--border);
}

.dropdown-item.active {
    background: var(--accent);
    color: white;
}

.dropdown-item.active svg {
    opacity: 1;
}

/* Dropdown Item with Action Button */
.dropdown-item-with-action {
    display: flex;
    align-items: center;
}

.dropdown-item-with-action .dropdown-item {
    flex: 1;
}

.dropdown-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    margin-right: 8px;
}

.dropdown-item-with-action:hover .dropdown-item-delete {
    opacity: 1;
}

.dropdown-item-delete:hover {
    color: var(--danger);
}

.dropdown-item svg {
    opacity: 0.6;
    flex-shrink: 0;
}

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

/* ================================
   BUTTONS
   ================================ */
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--divider);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px !important;
    font-size: 13px !important;
}

/* ================================
   FORMS
   ================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 16px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.select-wrapper {
    position: relative;
}

.select-wrapper svg {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
}

.form-select {
    appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.slider-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.slider-label-lg {
    font-size: 20px;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* ================================
   TOAST NOTIFICATIONS
   ================================ */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

@supports (padding: env(safe-area-inset-bottom)) {
    #toast-container {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

.toast {
    background: var(--surface-elevated);
    color: var(--text);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    pointer-events: auto;
}

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

.toast.success {
    border-left: 4px solid var(--success);
}

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

/* ================================
   IMPORT/EXPORT
   ================================ */
.io-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.io-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.io-card:hover {
    background: var(--divider);
    border-color: var(--accent);
}

.io-card:active {
    transform: scale(0.98);
}

.io-icon {
    color: var(--accent);
}

.io-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.io-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.io-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.io-info svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.io-divider {
    height: 1px;
    background: var(--divider);
    margin: 16px 0;
}

.io-card.io-secure {
    border-color: var(--accent);
}

.io-card.io-secure .io-icon {
    color: var(--success);
}

.encryption-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 149, 0, 0.1);
    border: 1px solid rgba(255, 149, 0, 0.3);
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

.encryption-warning svg {
    color: #ff9500;
    flex-shrink: 0;
    margin-top: 2px;
}

.encryption-warning span {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}
