@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap');

:root {
    --bg-dark: #0d0d0d;
    --bg-sidebar: #141414;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --bg-input: #252525;
    --border: #2e2e2e;
    --border-light: #3a3a3a;
    --gold: #c89b6d;
    --gold-light: #d4ad82;
    --brown: #8b5e3c;
    --brown-dark: #6b4528;
    --white: #ffffff;
    --text-muted: #a0a0a0;
    --text-secondary: #cccccc;
    --success: #2ecc71;
    --danger: #e74c3c;
    --info: #3498db;
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: all 0.25s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* ─── Layout ─── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.sidebar-brand h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 1px;
}

.sidebar-brand span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-link:hover {
    background: rgba(200, 155, 109, 0.08);
    color: var(--gold-light);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(139, 94, 60, 0.3), rgba(200, 155, 109, 0.15));
    color: var(--gold);
    border: 1px solid rgba(200, 155, 109, 0.2);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: var(--transition);
}

.sidebar-footer a:hover {
    color: var(--gold);
    background: rgba(200, 155, 109, 0.08);
}

/* ─── Main Content ─── */
.main-content {
    margin-right: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

/* ─── Header ─── */
.admin-header {
    height: var(--header-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--white);
}

.header-title span {
    color: var(--gold);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--bg-card);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(231, 76, 60, 0.08);
}

.btn-view-site {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--brown);
    color: var(--white);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-view-site:hover {
    background: var(--gold);
    color: var(--bg-dark);
}

/* ─── Page Body ─── */
.page-body {
    padding: 28px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ─── Stats Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.stat-card:hover {
    border-color: rgba(200, 155, 109, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(200, 155, 109, 0.12);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--gold);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ─── Products Grid ─── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    border-color: rgba(200, 155, 109, 0.35);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.product-card-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--bg-input);
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

.product-card-category {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: var(--gold);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.product-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 8px;
}

.product-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
    flex: 1;
}

.product-card-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 16px;
}

.product-card-price span {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.product-card-actions {
    display: flex;
    gap: 10px;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brown), var(--brown-dark));
    color: var(--white);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--gold), var(--brown));
    color: var(--bg-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 155, 109, 0.3);
}

.btn-edit {
    flex: 1;
    background: rgba(52, 152, 219, 0.12);
    color: var(--info);
    border: 1px solid rgba(52, 152, 219, 0.25);
}

.btn-edit:hover {
    background: var(--info);
    color: var(--white);
}

.btn-delete {
    flex: 1;
    background: rgba(231, 76, 60, 0.12);
    color: var(--danger);
    border: 1px solid rgba(231, 76, 60, 0.25);
}

.btn-delete:hover {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
}

/* ─── Form Card ─── */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 640px;
    margin: 0 auto;
    box-shadow: var(--shadow-sm);
}

.form-card-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.form-card-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
}

.form-card-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(200, 155, 109, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    padding-left: 40px;
}

/* ─── Custom File Upload ─── */
.file-upload {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: var(--bg-input);
}

.file-upload:hover,
.file-upload.dragover {
    border-color: var(--gold);
    background: rgba(200, 155, 109, 0.05);
}

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.file-upload-icon {
    width: 56px;
    height: 56px;
    background: rgba(200, 155, 109, 0.12);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--gold);
}

.file-upload-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-upload-name {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--gold);
    font-weight: 500;
}

.image-preview {
    margin-top: 16px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: none;
    border: 1px solid var(--border);
}

.image-preview.visible {
    display: block;
}

.image-preview img {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
}

/* ─── Current Image (edit) ─── */
.current-image {
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    max-width: 200px;
}

.current-image img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

/* ─── Toast ─── */
.toast-container {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toastIn 0.35s ease, toastOut 0.35s ease 3.5s forwards;
    min-width: 280px;
    max-width: 420px;
}

.toast-success {
    background: #1a3a2a;
    border: 1px solid rgba(46, 204, 113, 0.4);
    color: #2ecc71;
}

.toast-error {
    background: #3a1a1a;
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #e74c3c;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-20px); }
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ─── Categories Table ─── */
.data-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--bg-input);
    padding: 14px 20px;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(200, 155, 109, 0.04);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(200, 155, 109, 0.15);
    color: var(--gold);
}

/* ─── Settings ─── */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.settings-row span {
    color: var(--white);
    font-weight: 500;
}

/* ─── Recent Products (dashboard) ─── */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title a {
    font-size: 0.85rem;
    color: var(--gold);
    font-weight: 500;
}

.section-title a:hover {
    text-decoration: underline;
}

/* ─── Sidebar Overlay (mobile) ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
}

.sidebar-overlay.active {
    display: block;
}

/* ─── Delete Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    padding: 32px 28px 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    transform: scale(0.9) translateY(10px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-box {
    transform: scale(1) translateY(0);
}

.modal-icon {
    width: 64px;
    height: 64px;
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: var(--danger);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
}

.modal-product-name {
    font-size: 0.95rem;
    color: var(--gold);
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 28px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions .btn {
    flex: 1;
    padding: 12px 20px;
}

.btn-cancel {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background: var(--border);
    color: var(--white);
}

.btn-confirm-delete {
    background: var(--danger);
    color: var(--white);
}

.btn-confirm-delete:hover {
    background: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.35);
}

/* ─── Login Page ─── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand h1 {
    font-size: 1.8rem;
    color: var(--gold);
    font-weight: 700;
}

.login-brand p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 6px;
}

.login-error {
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 20px;
    text-align: center;
}

/* ─── Responsive ─── */
@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    .menu-toggle {
        display: flex;
    }

    .page-body {
        padding: 20px 16px;
    }

    .form-card {
        padding: 24px 20px;
    }

    .admin-header {
        padding: 0 16px;
    }

    .btn-view-site span {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .product-card-actions {
        flex-direction: column;
    }
}
