/* ═══════════════════════════════════════════════════════════
   Admin Panel — Visual UX Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Login Card ──────────────────────────────────────────── */
.login-card {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, .2);
}

.login-card input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .2);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-btn {
    position: relative;
    padding: .75rem 1.5rem;
    font-weight: 600;
    font-size: .875rem;
    border-radius: .75rem .75rem 0 0;
    transition: all .25s ease;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
}

.tab-btn:hover {
    color: #334155;
    background: rgba(241, 245, 249, .6);
}

.tab-btn.active {
    color: #6366f1;
    background: white;
    box-shadow: 0 -2px 8px rgba(99, 102, 241, .1);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 3px 3px 0 0;
}

.tab-btn .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 .4rem;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 9999px;
    margin-left: .4rem;
    background: #e2e8f0;
    color: #475569;
    transition: all .25s;
}

.tab-btn.active .badge {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

/* ── Admin app wrapper ────────────────────────────────────── */
#admin-app {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
}

/* ── Panel container ─────────────────────────────────────── */
.admin-panel {
    background: white;
    border-radius: 0 0 1rem 1rem;
    border: 1px solid #e2e8f0;
    border-top: 0;
    width: 100%;
    min-height: 60vh;
    box-sizing: border-box;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: .75rem;
}

.panel-body {
    padding: 1.5rem;
}

/* ── Action buttons ──────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    font-size: .8rem;
    font-weight: 600;
    border-radius: .5rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-color: #6366f1;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, .4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: #475569;
    border-color: #e2e8f0;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-danger {
    background: white;
    color: #ef4444;
    border-color: #fecaca;
}

.btn-danger:hover {
    background: #fef2f2;
}

.btn-sm {
    padding: .35rem .65rem;
    font-size: .75rem;
}

.btn-icon {
    padding: .4rem;
    width: 2rem;
    height: 2rem;
    justify-content: center;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(34, 197, 94, .4);
}

/* ── Search ──────────────────────────────────────────────── */
.search-input {
    padding: .5rem 1rem .5rem 2.25rem;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    font-size: .85rem;
    background: #f8fafc;
    width: 100%;
    max-width: 300px;
    transition: all .2s;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
    background: white;
}

.search-wrap {
    position: relative;
}

.search-wrap i {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: .8rem;
}

/* ── Cards grid ──────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    padding: 1.25rem;
    transition: all .25s;
    position: relative;
}

.card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .08);
}

.card-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .75rem;
}

.card-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.card-title {
    font-weight: 700;
    font-size: .95rem;
    color: #1e293b;
}

.card-subtitle {
    font-size: .75rem;
    color: #94a3b8;
    margin-top: .15rem;
}

.card-body {
    font-size: .8rem;
    color: #64748b;
    line-height: 1.5;
}

.card-actions {
    display: flex;
    gap: .4rem;
    position: absolute;
    top: .75rem;
    right: .75rem;
    opacity: 0;
    transition: opacity .2s;
}

.card:hover .card-actions {
    opacity: 1;
}

/* ── Badges / Chips ──────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .6rem;
    font-size: .7rem;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid;
}

.chip-category {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.chip-tag {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.chip-tone {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.chip-format {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

.chip-mode {
    background: #f0fdf4;
    color: #166534;
    border-color: #86efac;
}

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .5rem;
}

/* ── Master-Detail layout ────────────────────────────────── */
.master-detail {
    display: flex;
    gap: 0;
    min-height: 60vh;
    width: 100%;
}

.master-list {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    max-height: 70vh;
    background: #fafbfc;
}

.master-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1rem;
    cursor: pointer;
    transition: all .15s;
    border-bottom: 1px solid #f1f5f9;
    font-size: .85rem;
    color: #475569;
}

.master-item:hover {
    background: #f1f5f9;
}

.master-item.active {
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600;
    border-right: 3px solid #6366f1;
}

.master-item .item-icon {
    width: 2rem;
    height: 2rem;
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    flex-shrink: 0;
}

.detail-panel {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 70vh;
}

.detail-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    font-size: .9rem;
}

/* ── Section Headers ─────────────────────────────────────── */
.section-title {
    font-size: .8rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* ── Info Grid (key-value pairs) ─────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.info-item label {
    display: block;
    font-size: .7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .25rem;
}

.info-item .info-value {
    font-size: .85rem;
    color: #1e293b;
    font-weight: 500;
}

/* ── Sub-tabs (for Vision) ───────────────────────────────── */
.sub-tabs {
    display: flex;
    gap: .25rem;
    padding: .25rem;
    background: #f1f5f9;
    border-radius: .5rem;
    margin-bottom: 1rem;
}

.sub-tab {
    padding: .5rem 1rem;
    font-size: .8rem;
    font-weight: 600;
    border-radius: .375rem;
    border: none;
    cursor: pointer;
    transition: all .2s;
    background: transparent;
    color: #64748b;
    font-family: inherit;
}

.sub-tab:hover {
    color: #334155;
}

.sub-tab.active {
    background: white;
    color: #6366f1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem;
    overflow-y: auto;
    animation: fadeIn .2s ease-out;
}

.modal {
    background: white;
    border-radius: 1rem;
    width: 100%;
    max-width: 720px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .2);
    animation: slideUp .3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1.2rem;
    padding: .25rem;
    transition: color .2s;
}

.modal-close:hover {
    color: #ef4444;
}

.modal-body {
    padding: 1.5rem;
    max-height: 65vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Form styles ─────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .35rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    font-size: .85rem;
    background: #f8fafc;
    transition: all .2s;
    font-family: inherit;
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
    background: white;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-textarea.large {
    min-height: 150px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-color-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.form-color {
    width: 2.5rem;
    height: 2.25rem;
    border: 1px solid #e2e8f0;
    border-radius: .375rem;
    padding: .125rem;
    cursor: pointer;
}

.form-lang-tabs {
    display: flex;
    gap: .25rem;
    margin-bottom: 1rem;
}

.form-lang-tab {
    padding: .35rem .75rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: .375rem;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all .2s;
    background: white;
    color: #64748b;
}

.form-lang-tab.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

/* ── Dynamic list (for instructions array) ───────────────── */
.dyn-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.dyn-list-item {
    display: flex;
    gap: .35rem;
    align-items: center;
}

.dyn-list-item input {
    flex: 1;
}

.dyn-list-item .btn-remove {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem;
    font-size: .85rem;
}

.dyn-add-btn {
    font-size: .75rem;
    color: #6366f1;
    background: none;
    border: 1px dashed #c7d2fe;
    border-radius: .375rem;
    padding: .35rem .75rem;
    cursor: pointer;
    transition: all .2s;
    width: 100%;
    margin-top: .25rem;
}

.dyn-add-btn:hover {
    background: #eef2ff;
}

/* ── Options table (for Vision) ──────────────────────────── */
.options-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.options-table th {
    text-align: left;
    padding: .5rem .5rem;
    font-size: .7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    border-bottom: 2px solid #e2e8f0;
}

.options-table td {
    padding: .35rem .5rem;
    border-bottom: 1px solid #f1f5f9;
}

.options-table input {
    border: 1px solid transparent;
    background: transparent;
    padding: .25rem .35rem;
    border-radius: .25rem;
    font-size: .8rem;
    width: 100%;
    transition: all .2s;
    font-family: inherit;
}

.options-table input:focus {
    border-color: #6366f1;
    background: white;
    outline: none;
}

.options-table tr:hover input {
    border-color: #e2e8f0;
    background: #f8fafc;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.25rem;
    border-radius: .75rem;
    font-size: .875rem;
    font-weight: 500;
    color: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .15);
    animation: toastIn .4s ease-out;
    min-width: 280px;
}

.toast.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.toast.fade-out {
    animation: toastOut .3s ease-in forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* ── Save bar (floating) ─────────────────────────────────── */
.save-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.5rem;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 1rem 1rem;
    z-index: 10;
}

.save-bar.hidden {
    display: none;
}

/* ── Confirm dialog ──────────────────────────────────────── */
.confirm-body {
    text-align: center;
    padding: 1rem 0;
}

.confirm-body i {
    font-size: 2.5rem;
    color: #ef4444;
    margin-bottom: .75rem;
}

.confirm-body p {
    font-size: .9rem;
    color: #475569;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: .75rem;
    display: block;
}

.empty-state p {
    font-size: .9rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .master-detail {
        flex-direction: column;
    }

    .master-list {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tab-btn {
        padding: .5rem .75rem;
        font-size: .75rem;
    }

    .modal {
        max-width: 95vw;
    }
}