/* ===================================
   SEL — Premium Dark Theme
   =================================== */

:root {
    --bg: #09090b;
    --bg-card: #111113;
    --bg-input: #18181b;
    --bg-hover: #1f1f23;
    --border: #27272a;
    --border-light: #3f3f46;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #FFA500;
    --accent-hover: #FFB733;
    --accent-soft: rgba(255, 165, 0, 0.08);
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.08);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-soft: rgba(239, 68, 68, 0.08);
    --info: #3b82f6;
    --info-soft: rgba(59, 130, 246, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.15s ease;
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --input-padding-y: 11px;
    --input-padding-x: 16px;
    --anim-fast: 0.15s;
    --anim-mid: 0.25s;
    --anim-slow: 0.4s;
    --focus-ring: 0 0 0 3px rgba(255, 165, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent);
    color: #000;
}

/* ===================================
   Login / Register
   =================================== */

.container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.form-container {
    background: var(--bg-card);
    padding: 40px 44px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    animation: formAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes formAppear {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fieldSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.form-container .form-group:nth-child(1) { animation: fieldSlideIn 0.35s 0.08s both; }
.form-container .form-group:nth-child(2) { animation: fieldSlideIn 0.35s 0.16s both; }
.form-container .form-group:nth-child(3) { animation: fieldSlideIn 0.35s 0.24s both; }
.form-container .form-group:nth-child(4) { animation: fieldSlideIn 0.35s 0.32s both; }
.form-container .form-group:nth-child(5) { animation: fieldSlideIn 0.35s 0.40s both; }

h1 {
    margin-bottom: 32px;
    color: var(--text);
    text-align: center;
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
}

/* ===================================
   Forms
   =================================== */

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: var(--input-padding-y) var(--input-padding-x);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

select {
    cursor: pointer;
}

select option {
    background: var(--bg-input);
    color: var(--text);
}

.hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* ===================================
   Buttons
   =================================== */

.btn-primary {
    width: 100%;
    padding: 11px 20px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.97);
    transition-duration: 0.08s;
}

.btn-primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 7px 16px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all var(--transition);
}

.btn-secondary:hover {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
    background: var(--danger-soft);
}

/* ===================================
   Feedback Messages
   =================================== */

.error-message {
    margin-top: 15px;
    padding: 12px 14px;
    background: var(--danger-soft);
    color: var(--danger);
    border-radius: var(--radius);
    border: 1px solid rgba(239, 68, 68, 0.15);
    display: none;
    font-size: 13px;
}

.error-message.show {
    display: block;
}

.success-message {
    margin-top: 15px;
    padding: 12px 14px;
    background: var(--success-soft);
    color: var(--success);
    border-radius: var(--radius);
    border: 1px solid rgba(34, 197, 94, 0.15);
    display: none;
    font-size: 13px;
}

.success-message.show {
    display: block;
}

/* ===================================
   Links
   =================================== */

.link-text {
    margin-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.link-text a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.link-text a:hover {
    color: var(--accent-hover);
}

/* ===================================
   Dashboard / Settings
   =================================== */

.dashboard-container {
    min-height: 100vh;
    background: var(--bg);
    width: 100%;
}

.dashboard-header {
    background: var(--bg-card);
    padding: 14px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.dashboard-header h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info span {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
}

.user-info a,
.catalog-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: color var(--transition);
}

.user-info a:hover,
.catalog-nav a:hover {
    color: var(--accent);
}

.dashboard-content {
    max-width: 720px;
    margin: 40px auto;
    padding: 0 24px;
}

.dashboard-content form {
    background: var(--bg-card);
    padding: 32px 36px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    animation: formAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.dashboard-content h2 {
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.dashboard-content h2:first-child {
    margin-top: 0;
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* ===================================
   Catalog — Nav & Actions
   =================================== */

.catalog-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.catalog-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn-add,
.btn-import,
.btn-export,
.btn-delete-all {
    padding: 8px 18px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition);
}

.btn-add {
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.25);
}
.btn-add:hover {
    background: var(--success-soft);
    border-color: rgba(34, 197, 94, 0.4);
}

.btn-import {
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.25);
}
.btn-import:hover {
    background: var(--info-soft);
    border-color: rgba(59, 130, 246, 0.4);
}

.btn-export {
    color: var(--accent);
    border-color: rgba(255, 165, 0, 0.25);
}
.btn-export:hover {
    background: var(--accent-soft);
    border-color: rgba(255, 165, 0, 0.4);
}

.btn-delete-all {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.25);
}
.btn-delete-all:hover {
    background: var(--danger-soft);
    border-color: rgba(239, 68, 68, 0.4);
}

/* ===================================
   Catalog — Products Table
   =================================== */

.products-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.products-table th,
.products-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.products-table th {
    background: transparent;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.products-table td {
    color: var(--text-secondary);
    font-size: 14px;
}

.products-table tbody tr {
    transition: background 0.25s ease, transform 0.15s ease;
}

.products-table tbody tr:hover {
    transform: translateX(2px);
}

.products-table tbody tr:hover td {
    background: var(--bg-hover);
}

.btn-edit,
.btn-delete {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition);
}

.btn-edit {
    color: var(--accent);
    border-color: rgba(255, 165, 0, 0.25);
    margin-right: 6px;
}
.btn-edit:hover {
    background: var(--accent-soft);
    border-color: rgba(255, 165, 0, 0.4);
}

.btn-delete {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.25);
}
.btn-delete:hover {
    background: var(--danger-soft);
    border-color: rgba(239, 68, 68, 0.4);
}

/* ===================================
   Catalog — Modals
   =================================== */

.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: visibility var(--anim-mid), opacity var(--anim-mid);
}

.modal.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: calc(100% - 32px);
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.94) translateY(8px);
    opacity: 0;
    transition: transform var(--anim-mid) cubic-bezier(0.16, 1, 0.3, 1), opacity var(--anim-mid);
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 0;
    text-transform: none;
    letter-spacing: -0.02em;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.modal-actions .btn-primary {
    width: auto;
    padding: 10px 28px;
}

.btn-cancel {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all var(--transition);
}

.btn-cancel:hover {
    color: var(--text);
    border-color: var(--border-light);
}

/* ===================================
   Catalog — Empty State & File Upload
   =================================== */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 6px;
    font-size: 14px;
}

.file-upload {
    border: 1px dashed var(--border-light);
    padding: 28px 20px;
    text-align: center;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 16px;
    transition: all var(--transition);
    color: var(--text-muted);
    font-size: 14px;
}

.file-upload:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text-secondary);
}

.file-upload input {
    display: none;
}

.products-count {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

/* ===================================
   Scrollbar (global)
   =================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ===================================
   Toast Notifications
   =================================== */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    min-width: 280px;
    max-width: 400px;
    animation: slideInRight 0.25s ease;
    pointer-events: all;
    font-size: 14px;
    color: var(--text);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--info); }

.toast.removing {
    animation: slideOutRight 0.25s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(110%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%); opacity: 0; }
}

/* ===================================
   Skeleton Loader
   =================================== */

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-item {
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.skeleton-line { height: 12px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 90%; }

/* ===================================
   Accordion
   =================================== */

.accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.accordion-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-input);
    transition: background var(--transition), color var(--transition);
    user-select: none;
}

.accordion-header:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.accordion-item.open > .accordion-header {
    color: var(--accent);
    background: var(--accent-soft);
    border-bottom: 1px solid var(--border);
}

.accordion-icon {
    font-style: normal;
    font-size: 12px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.accordion-item.open > .accordion-header .accordion-icon {
    transform: rotate(0deg);
    opacity: 1;
}

.accordion-item:not(.open) > .accordion-header .accordion-icon {
    transform: rotate(-90deg);
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    padding: 0 18px;
    background: var(--bg-card);
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1), padding 0.32s;
}

.accordion-item.open > .accordion-body {
    max-height: 600px;
    padding: 20px 18px;
    transition: max-height 0.38s cubic-bezier(0.16, 1, 0.3, 1), padding 0.32s;
}

/* ===================================
   Modal Animations
   =================================== */

.delete-modal-overlay { animation: fadeIn 0.2s ease; }
.delete-modal-box { animation: scaleIn 0.2s ease; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ===================================
   Form Control
   =================================== */

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text);
    transition: border-color var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

.form-control::placeholder { color: var(--text-muted); }

/* ===================================
   Sortable Table Headers
   =================================== */

.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover { color: var(--text-secondary); }

.sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.5;
    font-style: normal;
}

/* ===================================
   Responsive — Mobile
   =================================== */

@media (max-width: 640px) {
    .dashboard-header {
        padding: 12px 16px;
    }

    .dashboard-content {
        padding: 0 16px;
    }

    .dashboard-content form {
        padding: 24px 20px;
    }

    .form-container {
        padding: 32px 24px;
    }

    .modal-content {
        padding: 24px 20px;
    }

    .products-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .products-table td:first-child,
    .products-table th:first-child {
        white-space: normal;
        min-width: 120px;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ===================================
   Reduced Motion Guard
   =================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
