/* Admin Area Styles */

/* Admin Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
    background: #f1f5f9;
}

/* Admin Sidebar */
.admin-sidebar {
    width: 250px;
    background: #1e293b;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
}

.admin-logo {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #334155;
}

.admin-logo img {
    width: 40px;
    height: 40px;
}

.admin-logo span {
    font-size: 1.25rem;
    font-weight: 600;
}

.admin-nav {
    flex: 1;
    padding: 1rem 0;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.admin-nav-item:hover {
    background: #334155;
    color: white;
}

.admin-nav-item.active {
    background: #334155;
    color: white;
    border-left: 3px solid #3b82f6;
}

.admin-nav-item .icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.admin-nav-footer {
    padding: 1rem 0;
    border-top: 1px solid #334155;
}

/* Admin Main Content Area */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 250px;
}

/* Admin Top Bar */
.admin-topbar {
    background: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 40;
}

.admin-topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #1e293b;
}

.admin-topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
}

/* Admin Content */
.admin-content {
    padding: 2rem;
    flex: 1;
}

/* Admin Dashboard */
.admin-dashboard h2 {
    margin-bottom: 1rem;
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 600;
}

.admin-welcome {
    color: #64748b;
    margin-bottom: 1.5rem;
}

.admin-placeholder {
    background: white;
    border-radius: 0.5rem;
    padding: 3rem;
    text-align: center;
    color: #64748b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Loading State */
.admin-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    background: #f1f5f9;
}

.admin-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: admin-spin 1s linear infinite;
}

.admin-loading p {
    margin-top: 1rem;
    color: #64748b;
}

@keyframes admin-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Unauthorized State */
.admin-unauthorized {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    background: #f1f5f9;
    padding: 2rem;
}

.admin-unauthorized h1 {
    color: #dc2626;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.admin-unauthorized p {
    color: #64748b;
    margin-bottom: 1.5rem;
}

.btn-back {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #3b82f6;
    color: white;
    border-radius: 0.375rem;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-back:hover {
    background: #2563eb;
    color: white;
}

/* Admin Cards (for future dashboard) */
.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.admin-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-card-title {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.admin-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
}

.admin-card-link {
    text-decoration: none;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.admin-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.admin-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.admin-card-content {
    flex: 1;
}

.admin-card-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.admin-card-description {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
}

/* Scraper Operations Page */
.scraper-operations-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.page-header h2 {
    margin: 0 0 0.5rem 0;
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 600;
}

.page-description {
    color: #64748b;
    margin: 0;
}

/* Filters Card */
.filters-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filters-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.btn-reset {
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-reset:hover {
    background: #e2e8f0;
    color: #475569;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
}

.filter-group select,
.filter-group input[type="date"] {
    padding: 0.625rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #1e293b;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-group select:focus,
.filter-group input[type="date"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Results Card */
.results-card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.results-count {
    font-size: 0.875rem;
    color: #64748b;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-size-selector label {
    font-size: 0.875rem;
    color: #64748b;
}

.page-size-selector select {
    padding: 0.375rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

/* Loading Container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #64748b;
}

.loading-container .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: admin-spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Error Container */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.error-message {
    color: #dc2626;
    margin-bottom: 1rem;
}

.btn-retry {
    padding: 0.625rem 1.25rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-retry:hover {
    background: #2563eb;
}

/* Data Table */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    background: #f8fafc;
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table .cell-id {
    font-weight: 600;
    color: #3b82f6;
}

.data-table .cell-cost {
    font-family: monospace;
    text-align: right;
}

.data-table .cell-date {
    white-space: nowrap;
    color: #64748b;
}

.data-table .empty-row {
    text-align: center;
    color: #94a3b8;
    padding: 3rem 1rem;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-operation {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-processing {
    background: #dbeafe;
    color: #1e40af;
}

.badge-completed {
    background: #d1fae5;
    color: #065f46;
}

.badge-failed {
    background: #fee2e2;
    color: #991b1b;
}

.badge-cancelled {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-default {
    background: #f1f5f9;
    color: #475569;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: white;
    color: #475569;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.pagination-info {
    margin-left: 1rem;
    font-size: 0.875rem;
    color: #64748b;
}

/* Text Input Filters */
.filter-group input[type="text"] {
    padding: 0.625rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #1e293b;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-group input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-group input[type="text"]::placeholder {
    color: #94a3b8;
}

/* ========================================
   Dashboard Acquisti Page Styles
   ======================================== */

.dashboard-acquisti-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Filters Header Actions */
.filters-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-toggle-filters {
    padding: 0.5rem 1rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-toggle-filters:hover {
    background: #2563eb;
}

/* Filters Sections */
.filters-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.filters-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.filters-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Services Filter Grid */
.filters-grid-services {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.filter-checkbox select {
    width: 100%;
}

/* Dashboard Acquisti Table */
.data-table-acquisti {
    min-width: 950px;
}

.data-table-acquisti .col-action {
    width: 60px;
    text-align: center;
}

.data-table-acquisti .cell-action {
    text-align: center;
}

.btn-view-detail {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-view-detail:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.btn-view-detail:active {
    transform: scale(0.95);
}

.btn-view-detail svg {
    width: 16px;
    height: 16px;
}

.data-table-acquisti .col-id {
    width: 80px;
}

.data-table-acquisti .col-utente {
    min-width: 200px;
}

.data-table-acquisti .col-immobile {
    min-width: 180px;
}

.data-table-acquisti .col-date {
    width: 120px;
}

.data-table-acquisti .col-money {
    width: 120px;
}

.data-table-acquisti .col-services {
    min-width: 180px;
}

/* Utente Info Cell */
.utente-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.utente-nome {
    font-weight: 500;
    color: #1e293b;
}

.utente-email {
    font-size: 0.75rem;
    color: #64748b;
}

/* Immobile Info Cell */
.immobile-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.immobile-tipo {
    font-weight: 500;
    color: #1e293b;
}

.immobile-comune {
    font-size: 0.75rem;
    color: #64748b;
}

/* Money Cell */
.cell-money {
    font-family: monospace;
    text-align: right;
    white-space: nowrap;
}

/* Services Badges */
.services-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.badge-service {
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

.badge-base {
    background: #dbeafe;
    color: #1e40af;
}

.badge-dd {
    background: #fce7f3;
    color: #9d174d;
}

.badge-sp {
    background: #d1fae5;
    color: #065f46;
}

.badge-isp {
    background: #fef3c7;
    color: #92400e;
}

.badge-vm {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-vi {
    background: #ccfbf1;
    color: #0f766e;
}

.badge-vd {
    background: #f3e8ff;
    color: #7c3aed;
}

/* Expandable Row */
.data-table-acquisti tbody tr {
    cursor: pointer;
}

.data-table-acquisti tbody tr.row-expanded {
    background: #f8fafc;
}

.data-table-acquisti tbody tr.row-expanded:hover {
    background: #f8fafc;
}

/* Row Details */
.row-details {
    cursor: default !important;
}

.row-details:hover {
    background: white !important;
}

.row-details td {
    background: #f8fafc;
    padding: 0 !important;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.details-section h5 {
    margin: 0 0 0.75rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.details-content p {
    margin: 0 0 0.375rem 0;
    font-size: 0.8125rem;
    color: #475569;
}

.details-content p strong {
    color: #1e293b;
    font-weight: 500;
}

/* Services Detail */
.services-detail p {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.service-icon {
    width: 16px;
    text-align: center;
    font-weight: bold;
}

.service-active {
    color: #059669;
}

.service-active .service-icon {
    color: #059669;
}

.service-inactive {
    color: #94a3b8;
}

.service-inactive .service-icon {
    color: #dc2626;
}

/* Responsive */
@media (max-width: 1024px) {
    .details-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .details-section {
        padding-bottom: 1rem;
        border-bottom: 1px solid #e2e8f0;
    }

    .details-section:last-child {
        padding-bottom: 0;
        border-bottom: none;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-content {
        padding: 1rem;
    }

    .filters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .filters-actions {
        width: 100%;
        flex-direction: column;
    }

    .filters-actions button {
        width: 100%;
    }

    .results-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

/* Copy Button */
.btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    padding: 0.125rem 0.25rem;
    margin-left: 0.5rem;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.15s ease;
    vertical-align: middle;
}

.btn-copy:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.btn-copy:active {
    background: #e5e7eb;
}

.btn-copy svg {
    display: block;
}