/* Admin Panel Styles */

:root {
    --admin-primary: #2563eb;
    --admin-primary-hover: #1d4ed8;
    --admin-danger: #dc2626;
    --admin-danger-hover: #b91c1c;
    --admin-success: #16a34a;
    --admin-warning: #f59e0b;
    --admin-bg: #f8fafc;
    --admin-card-bg: #ffffff;
    --admin-border: #e2e8f0;
    --admin-text: #1e293b;
    --admin-text-light: #64748b;
    --admin-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --admin-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    background-color: var(--admin-bg);
    margin: 0;
    padding: 0;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--admin-card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--admin-shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-wide {
    max-width: 900px;
}

.payment-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.payment-modal-left,
.payment-modal-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.payment-modal-right {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.additional-charges-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #cbd5e1;
}

.additional-charges-header h4 {
    margin: 0;
    font-size: 1rem;
    color: #334155;
}

@media (max-width: 768px) {
    .payment-modal-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-wide {
        max-width: 600px;
    }
}

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

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--admin-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--admin-text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: var(--admin-border);
    color: var(--admin-text);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Login Form */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header img {
    margin-bottom: 0.75rem;
    display: inline-block;
}

.login-header h2 {
    margin: 0 0 0.5rem 0;
    color: var(--admin-text);
}

.login-header p {
    color: var(--admin-text-light);
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Admin Container */
.admin-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-header {
    background-color: var(--admin-card-bg);
    border-bottom: 1px solid var(--admin-border);
    padding: 1.5rem 2rem;
    box-shadow: var(--admin-shadow);
}

.admin-header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-section img {
    height: 40px;
    width: auto;
}

.logo-section h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--admin-text);
}

.logo-section p {
    margin: 0;
    color: var(--admin-text-light);
    font-size: 0.875rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Main Content */
.admin-main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.admin-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

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

.btn span {
    font-size: 1rem;
    line-height: 1;
}

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

.btn-primary:hover {
    background-color: var(--admin-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.btn-secondary {
    background-color: var(--admin-border);
    color: var(--admin-text);
}

.btn-secondary:hover {
    background-color: #cbd5e1;
}

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

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

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--admin-text);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    box-sizing: border-box;
}

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

.form-group small {
    display: block;
    margin-top: 0.375rem;
    color: var(--admin-text-light);
    font-size: 0.75rem;
}

/* Table Styles */
.clients-table-container {
    background-color: var(--admin-card-bg);
    border-radius: 12px;
    box-shadow: var(--admin-shadow);
    overflow: hidden;
}

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

.clients-table thead {
    background-color: var(--admin-bg);
}

.clients-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--admin-text);
    font-size: 0.875rem;
    border-bottom: 2px solid var(--admin-border);
}

.clients-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--admin-border);
    font-size: 0.875rem;
    color: var(--admin-text);
}

.clients-table tbody tr:hover {
    background-color: var(--admin-bg);
}

.clients-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    min-width: 60px;
    text-align: center;
}

/* Cost Center statuses */
.status-active {
    background-color: #16a34a;
    color: #ffffff !important;
}

.status-inactive {
    background-color: #dc2626;
    color: #ffffff !important;
}

.status-expiring {
    background-color: #f59e0b;
    color: #ffffff !important;
}

.status-demo {
    background-color: #d97706;
    color: #ffffff !important;
    font-weight: 600;
}

/* Payment & Extra Charge statuses */
.status-paid {
    background-color: #16a34a;
    color: #ffffff !important;
}

.status-unpaid {
    background-color: #dc2626;
    color: #ffffff !important;
}

.status-partial {
    background-color: #f59e0b;
    color: #ffffff !important;
}

.status-pending {
    background-color: #f59e0b;
    color: #ffffff !important;
}

.status-overdue {
    background-color: #b91c1c;
    color: #ffffff !important;
}

.license-type {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.action-btn.edit-btn {
    background-color: #dbeafe;
    color: #1e40af;
}

.action-btn.edit-btn:hover {
    background-color: #bfdbfe;
}

.action-btn.delete-btn {
    background-color: #fee2e2;
    color: #b91c1c;
}

.action-btn.delete-btn:hover {
    background-color: #fecaca;
}

/* Icon buttons for table actions */
.btn-icon {
    padding: 0.375rem 0.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: #f1f5f9;
    transform: scale(1.1);
}

/* Action buttons wrapper for table cells */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* Specific action button styles */
.action-btn-edit {
    background-color: #dbeafe;
    color: #1e40af;
}

.action-btn-edit:hover {
    background-color: #bfdbfe;
}

.action-btn-delete {
    background-color: #fee2e2;
    color: #b91c1c;
}

.action-btn-delete:hover {
    background-color: #fecaca;
}

.action-btn-success {
    background-color: #d1fae5;
    color: #065f46;
}

.action-btn-success:hover {
    background-color: #a7f3d0;
}

.action-btn-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.action-btn-info:hover {
    background-color: #bfdbfe;
}

/* Error Message */
.error-message {
    color: var(--admin-danger);
    background-color: #fee2e2;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-top: 1rem;
    font-size: 0.875rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* Delete Modal Styles */
.delete-info {
    background-color: var(--admin-bg);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.875rem;
}

.warning-text {
    color: var(--admin-warning);
    font-weight: 600;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.info-text {
    color: var(--admin-text-light);
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 1rem 0;
    padding: 0.75rem;
    background-color: #eff6ff;
    border-left: 3px solid var(--admin-primary);
    border-radius: 4px;
}

/* Custom Fields Section */
.custom-fields-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--admin-border);
}

.custom-fields-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.custom-fields-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--admin-text);
}

#customFieldsContainer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.custom-field-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 0.75rem;
    background-color: var(--admin-bg);
    border-radius: 6px;
    border: 1px solid var(--admin-border);
}

.custom-field-item .form-group {
    margin-bottom: 0;
    flex: 1;
}

.custom-field-item input,
.custom-field-item select {
    width: 100%;
}

.custom-field-remove {
    background-color: var(--admin-danger);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    align-self: flex-end;
}

.custom-field-remove:hover {
    background-color: var(--admin-danger-hover);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--admin-text-light);
}

.empty-state h3 {
    margin: 0 0 0.5rem 0;
    color: var(--admin-text);
}

/* Tab Navigation */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 2rem 0;
    max-width: 1400px;
    margin: 0 auto;
    border-bottom: 2px solid var(--admin-border);
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--admin-text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--admin-primary);
    background-color: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
    color: var(--admin-primary);
    border-bottom-color: var(--admin-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Search and Filter */
.search-filter-group {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    padding: 0.625rem 1rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    font-size: 0.875rem;
    min-width: 250px;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    background-color: white;
}

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

.filter-select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    font-size: 0.875rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    min-width: 150px;
    font-weight: 500;
}

.filter-select:hover {
    border-color: #94a3b8;
}

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

/* Cost Centers Table */
.costcenters-table th:nth-child(1) { width: 12%; }
.costcenters-table th:nth-child(2) { width: 15%; }
.costcenters-table th:nth-child(3) { width: 12%; }
.costcenters-table th:nth-child(4) { width: 12%; }
.costcenters-table th:nth-child(5) { width: 10%; }
.costcenters-table th:nth-child(6) { width: 8%; }
.costcenters-table th:nth-child(7) { width: 8%; }
.costcenters-table th:nth-child(8) { width: 8%; }
.costcenters-table th:nth-child(9) { width: 7%; }
.costcenters-table th:nth-child(10) { width: 8%; }

/* Modal Sizes */
.modal-large {
    max-width: 800px;
}

/* Form Row for Side-by-Side Fields */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Reports Section */
.reports-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.report-section {
    background-color: var(--admin-card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--admin-shadow);
}

.report-section h2 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    color: var(--admin-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.report-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 12px;
    color: white;
    box-shadow: var(--admin-shadow);
    transition: transform 0.2s;
}

.report-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.report-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.report-card:hover {
    transform: translateY(-2px);
}

.report-card .card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.report-card h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 500;
}

.report-card .metric {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.report-card .metric-small {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 0 0 0.5rem 0;
}

/* Status Chart */
.status-chart {
    padding: 1rem 0;
}

.status-bar {
    display: flex;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--admin-shadow);
}

.status-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    position: relative;
    min-width: 60px;
}

.status-segment:hover {
    opacity: 0.9;
}

.status-label {
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.status-active {
    background-color: var(--admin-success);
}

.status-inactive {
    background-color: var(--admin-danger);
}

.status-demo {
    background-color: var(--admin-warning);
}

/* Table Container for Reports */
.table-container {
    margin-top: 1rem;
}

.table-container table {
    width: 100%;
}

/* Status Badge Variations */
.status-demo {
    background-color: #fef3c7;
    color: var(--admin-warning);
}

/* Responsive Design */
@media (max-width: 768px) {
    .admin-header {
        padding: 1rem;
    }
    
    .admin-header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .logo-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .logo-section img {
        height: 32px;
    }
    
    .logo-section h1 {
        font-size: 1.25rem;
    }
    
    .logo-section p {
        font-size: 0.75rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .header-actions .btn {
        flex: 1;
    }

    .admin-main {
        padding: 1rem;
    }

    .admin-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Make table responsive - card view */
    .clients-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .clients-table {
        display: block;
        overflow-x: auto;
    }
    
    .clients-table thead {
        display: none;
    }
    
    .clients-table tbody {
        display: block;
    }
    
    .clients-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--admin-border);
        border-radius: 8px;
        background-color: var(--admin-card-bg);
        padding: 1rem;
    }
    
    .clients-table td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border-bottom: none;
    }
    
    .clients-table td::before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--admin-text-light);
        font-size: 0.75rem;
        text-transform: uppercase;
    }
    
    .action-buttons {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--admin-border);
    }
    
    .action-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        flex: 1;
    }

    .modal-content {
        width: 95%;
        padding: 1.25rem;
        max-height: 85vh;
    }
    
    .modal-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }
    
    .modal-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
    
    .custom-field-item {
        flex-direction: column;
    }
    
    .custom-field-remove {
        width: 100%;
        align-self: stretch;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Tabs */
    .admin-tabs {
        padding: 0.75rem 1rem 0;
        gap: 0.25rem;
        overflow-x: auto;
    }

    .tab-btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    /* Search and Filter */
    .search-filter-group {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        margin-top: 0.75rem;
    }

    .search-input {
        min-width: 100%;
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    /* Form Row */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Reports */
    .report-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .report-card {
        padding: 1.25rem;
    }

    .report-card .metric {
        font-size: 2rem;
    }

    .status-bar {
        flex-direction: column;
        height: auto;
    }

    .status-segment {
        min-height: 50px;
    }

    /* Cost Centers Table */
    .costcenters-table th,
    .costcenters-table td {
        min-width: 100px;
    }
}

@media (max-width: 480px) {
    .admin-header {
        padding: 0.75rem;
    }
    
    .admin-main {
        padding: 0.75rem;
    }
    
    .logo-section h1 {
        font-size: 1.125rem;
    }
    
    .btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .clients-table tr {
        padding: 0.75rem;
    }
    
    .modal-content {
        padding: 1rem;
        width: 98%;
    }
    
    .login-header h2 {
        font-size: 1.25rem;
    }
}

/* Payment Tracking Styles */
.payments-table td {
    font-size: 0.875rem;
}

.payments-table .actions {
    white-space: nowrap;
}
