/* IDIGOV Listing Manager Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --success: #16a34a;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

header .subtitle {
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

.header-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-600);
    letter-spacing: 0.01em;
}

.header-divider {
    width: 1px;
    height: 1.25rem;
    background: var(--gray-300);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

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

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
}

/* Table */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
}

td {
    font-size: 14px;
}

tbody tr:hover {
    background: var(--gray-50);
}

.listing-thumb {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
}

.listing-title {
    font-weight: 500;
    color: var(--gray-900);
}

.listing-price {
    font-weight: 600;
    color: var(--primary);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-pending {
    background: #fef9c3;
    color: #854d0e;
}

.status-sold, .status-rented {
    background: var(--gray-200);
    color: var(--gray-600);
}

.actions-cell {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 8px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--gray-100);
}

.btn-icon.delete:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--danger);
}

/* Empty State */
.empty-state, .loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.loading-state {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

.modal-small {
    max-width: 400px;
    padding: 24px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Form */
form {
    padding: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
    margin-bottom: 20px;
}

label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.label-hint {
    font-weight: 400;
    color: var(--gray-400);
    font-size: 12px;
}

input, select, textarea {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Photo Upload */
.photo-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--gray-50);
}

.photo-upload-area:hover, .photo-upload-area.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-placeholder {
    color: var(--gray-500);
}

.upload-icon {
    display: block;
    font-size: 40px;
    margin-bottom: 10px;
    color: var(--gray-400);
}

.upload-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 8px;
}

.photo-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.preview-item {
    position: relative;
    width: 100px;
    height: 80px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.preview-item .remove-photo {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-item.main::after {
    content: 'Main';
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.btn-loading {
    display: none;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loading {
    display: inline;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--gray-800);
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}

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

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    margin: 20px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--gray-500);
    font-size: 0.875rem;
    font-weight: 400;
}

.login-box .form-group {
    margin-bottom: 20px;
}

.login-box input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
}

.btn-full {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.login-error {
    color: var(--danger);
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
}

/* Header with logout */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

[hidden] {
    display: none !important;
}

/* Full-screen Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.25rem;
    backdrop-filter: blur(4px);
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.loading-overlay.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.loading-overlay .overlay-spinner {
    width: 3.75rem;
    height: 3.75rem;
    border: 0.25rem solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay .overlay-text {
    color: white;
    font-size: 1.125rem;
    font-weight: 500;
    text-align: center;
}

.loading-overlay .overlay-subtext {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    margin-top: -0.75rem;
}

/* Logo Styles */
.login-logo {
    height: 2.5rem;
    width: auto;
    margin-bottom: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo {
    height: 1.75rem;
    width: auto;
}

/* Photo Selection for Main */
.preview-item {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.preview-item:hover {
    transform: scale(1.05);
}

.preview-item.main {
    box-shadow: 0 0 0 3px var(--primary);
}

.set-main-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.preview-item:hover .set-main-btn {
    opacity: 1;
}

.preview-item.main .set-main-btn {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row, .form-row.three-col {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 700px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .login-box {
        padding: 30px 24px;
    }
}
