/* ===========================
   DALWIN HOMES — Admin Panel Styles
   Premium Dark / Gold / Glassmorphism
   =========================== */

/* --- Admin Login Page --- */
.admin-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    position: relative;
    overflow: hidden;
}

.admin-login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(201, 168, 76, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(201, 168, 76, 0.05) 0%, transparent 50%);
    animation: adminBgShift 20s ease-in-out infinite alternate;
}

@keyframes adminBgShift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-5%, -5%); }
}

.admin-login-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.admin-login-logo {
    text-align: center;
    margin-bottom: 2.5rem;
}

.admin-login-logo .nav-logo {
    display: inline-flex;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.admin-login-logo p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.admin-form-group {
    margin-bottom: 1.5rem;
}

.admin-form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.admin-form-group input {
    width: 100%;
    padding: 0.9rem 1.2rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition-base);
    outline: none;
}

.admin-form-group input:focus {
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
    background: rgba(255, 255, 255, 0.08);
}

.admin-form-group input::placeholder {
    color: var(--color-text-dim);
}

.admin-login-btn {
    width: 100%;
    padding: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.admin-error {
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
    color: #e74c3c;
    font-size: 0.85rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.admin-error.visible {
    display: flex;
}

.admin-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
}

.admin-loading.visible {
    display: flex;
}

.admin-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(201, 168, 76, 0.3);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.admin-back-link {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--color-text-dim);
    font-size: 0.85rem;
    transition: color var(--transition-base);
}

.admin-back-link:hover {
    color: var(--color-gold);
}

/* --- Admin Dashboard Layout --- */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

.admin-sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid var(--color-border-light);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.admin-sidebar-logo {
    padding: 0.5rem 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border-light);
}

.admin-sidebar-logo .nav-logo {
    font-size: 1.4rem;
}

.admin-sidebar-logo p {
    font-size: 0.7rem;
    color: var(--color-gold);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-top: 0.2rem;
}

.admin-sidebar-nav {
    padding: 1.5rem 0;
    flex: 1;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-base);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
}

.admin-nav-item:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

.admin-nav-item.active {
    color: var(--color-gold);
    background: rgba(201, 168, 76, 0.08);
    border-right: 3px solid var(--color-gold);
}

.admin-nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.admin-sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border-light);
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.admin-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--color-bg);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.admin-user-name {
    font-size: 0.85rem;
    color: var(--color-text);
    font-weight: 500;
}

.admin-user-email {
    font-size: 0.7rem;
    color: var(--color-text-dim);
}

/* --- Main Content Area --- */
.admin-main {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 2.5rem;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border-light);
}

.admin-header h1 {
    font-size: 1.8rem;
    font-family: var(--font-heading);
}

.admin-header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* --- Stats Cards --- */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.admin-stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all var(--transition-base);
}

.admin-stat-card:hover {
    border-color: var(--color-border);
    box-shadow: var(--shadow-gold);
}

.admin-stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.admin-stat-card .stat-icon svg {
    width: 22px;
    height: 22px;
}

.admin-stat-card .stat-icon.gold {
    background: rgba(201, 168, 76, 0.12);
    color: var(--color-gold);
}

.admin-stat-card .stat-icon.green {
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
}

.admin-stat-card .stat-icon.blue {
    background: rgba(52, 152, 219, 0.12);
    color: #3498db;
}

.admin-stat-card .stat-icon.purple {
    background: rgba(155, 89, 182, 0.12);
    color: #9b59b6;
}

.admin-stat-card h3 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-text);
    margin-bottom: 0.3rem;
}

.admin-stat-card p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* --- Listings Table --- */
.admin-table-wrapper {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.admin-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--color-border-light);
}

.admin-table-header h2 {
    font-size: 1.1rem;
    font-family: var(--font-heading);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead th {
    padding: 1rem 1.2rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
    background: rgba(255, 255, 255, 0.02);
}

.admin-table tbody td {
    padding: 1rem 1.2rem;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.admin-table tbody tr {
    transition: background var(--transition-base);
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.admin-table-image {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--color-border-light);
}

.admin-table-title {
    font-weight: 500;
    color: var(--color-text);
}

.admin-table-location {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.admin-table-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 20px;
    background: rgba(201, 168, 76, 0.15);
    color: var(--color-gold);
    border: 1px solid rgba(201, 168, 76, 0.25);
}

.admin-table-badge.featured {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border-color: rgba(46, 204, 113, 0.25);
}

.admin-table-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-edit {
    background: rgba(52, 152, 219, 0.15);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.25);
}

.btn-edit:hover {
    background: rgba(52, 152, 219, 0.25);
}

.btn-delete {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.25);
}

.btn-delete:hover {
    background: rgba(231, 76, 60, 0.25);
}

.admin-empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.admin-empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--color-text-dim);
    margin-bottom: 1rem;
}

.admin-empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
}

.admin-empty-state p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* --- Modal --- */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.admin-modal-overlay.active {
    display: flex;
}

.admin-modal {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.admin-modal::-webkit-scrollbar {
    width: 6px;
}

.admin-modal::-webkit-scrollbar-track {
    background: transparent;
}

.admin-modal::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-border-light);
    position: sticky;
    top: 0;
    background: var(--color-bg-alt);
    z-index: 1;
}

.admin-modal-header h2 {
    font-size: 1.3rem;
    font-family: var(--font-heading);
}

.admin-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.admin-modal-close:hover {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.admin-modal-body {
    padding: 2rem;
}

.admin-modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--color-border-light);
    position: sticky;
    bottom: 0;
    background: var(--color-bg-alt);
}

/* --- Form Styles --- */
.admin-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.admin-form-group select,
.admin-form-group textarea {
    width: 100%;
    padding: 0.9rem 1.2rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all var(--transition-base);
    outline: none;
}

.admin-form-group select:focus,
.admin-form-group textarea:focus {
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}

.admin-form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a09888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.admin-form-group select option {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.admin-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.admin-form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.admin-form-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-gold);
    cursor: pointer;
}

.admin-form-checkbox label {
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

/* --- Image Upload --- */
.admin-image-upload {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
}

.admin-image-upload:hover,
.admin-image-upload.dragover {
    border-color: var(--color-gold);
    background: rgba(201, 168, 76, 0.05);
}

.admin-image-upload input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.admin-image-upload svg {
    width: 40px;
    height: 40px;
    color: var(--color-text-dim);
    margin-bottom: 0.8rem;
}

.admin-image-upload p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.admin-image-upload span {
    color: var(--color-gold);
    font-weight: 600;
}

.admin-image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.admin-image-preview {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border-light);
}

.admin-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-image-preview .remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.admin-image-preview:hover .remove-image {
    opacity: 1;
}

/* --- Delete Confirmation --- */
.admin-delete-confirm {
    text-align: center;
    padding: 1rem 0;
}

.admin-delete-confirm svg {
    width: 48px;
    height: 48px;
    color: #e74c3c;
    margin-bottom: 1rem;
}

.admin-delete-confirm h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.admin-delete-confirm p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 0 30px rgba(231, 76, 60, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-muted);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-text);
}

/* --- Toast Notification --- */
.admin-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    z-index: 3000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.admin-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.admin-toast.success {
    border-color: rgba(46, 204, 113, 0.3);
}

.admin-toast.error {
    border-color: rgba(231, 76, 60, 0.3);
}

.admin-toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.admin-toast.success .admin-toast-icon {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.admin-toast.error .admin-toast-icon {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* --- Public Listing Loader --- */
.listing-loader {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
}

.listing-loader .admin-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 1rem;
}

.listing-loader p {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* --- Mobile Sidebar --- */
.admin-sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 101;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.admin-sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: all var(--transition-base);
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

    .admin-sidebar.active {
        transform: translateX(0);
    }

    .admin-sidebar-toggle {
        display: flex;
    }

    .admin-main {
        margin-left: 0;
        padding: 1.5rem;
        padding-top: 4rem;
    }

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

    .admin-table {
        font-size: 0.8rem;
    }

    .admin-table thead th,
    .admin-table tbody td {
        padding: 0.7rem 0.8rem;
    }

    .admin-modal {
        max-width: 95vw;
        max-height: 90vh;
    }
}

@media (max-width: 768px) {
    .admin-stats {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .admin-login-card {
        margin: 1rem;
        padding: 2rem;
    }
}
