/* Admin Control Panel Styles */
.admin-body {
    background: var(--primary-bg);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
}

/* ===== ADMIN MODAL ===== */
.admin-modal {
    display: flex;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.admin-modal-content {
    background-color: var(--primary-bg);
    margin: 20px;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.3s ease;
}

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

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

.admin-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-close {
    color: var(--text-light);
    font-size: 1.5rem;
    text-decoration: none;
    transition: var(--transition);
}

.admin-close:hover {
    color: var(--text-primary);
}

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

.admin-back-link {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* ===== ADMIN DASHBOARD ===== */
.admin-dashboard {
    min-height: 100vh;
}

/* Admin Header */
.admin-header {
    background: var(--primary-bg);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.admin-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
}

.admin-brand .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.admin-welcome {
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Main Content */
.admin-main {
    padding: 2rem 0;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ===== TABS NAVIGATION ===== */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-button:hover {
    color: var(--text-primary);
    background: var(--secondary-bg);
}

.tab-button.active {
    color: var(--accent-color);
    background: var(--secondary-bg);
}

.tab-button i {
    font-size: 1.1rem;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.tab-header h3 {
    color: var(--text-primary);
    margin: 0;
}

.tab-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.tab-section h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== OVERVIEW TAB ===== */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.overview-card {
    background: var(--primary-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.overview-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.overview-icon {
    width: 60px;
    height: 60px;
    background: var(--secondary-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--accent-color);
}

.overview-info h3 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.overview-info p {
    color: var(--text-secondary);
    margin: 0;
}

.overview-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.stats-card {
    background: var(--primary-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.stats-card h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-weight: 600;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

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

.btn-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-action:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* ===== TABLES ===== */
.admin-table-container {
    background: var(--primary-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.admin-table th,
.admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.admin-table th {
    background: var(--secondary-bg);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-table td {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.admin-table tr:hover td {
    background: var(--secondary-bg);
}

.loading {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 2rem !important;
}

/* ===== CREATE FORMS ===== */
.create-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.create-form {
    background: var(--primary-bg);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.create-form h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== FORM STYLES - IMPROVED ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--primary-bg);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

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

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

/* Input readonly styling */
.form-group input[readonly] {
    background: var(--secondary-bg);
    border-color: var(--border-light);
    color: var(--text-primary);
    cursor: not-allowed;
    opacity: 1;
}

.form-group input[readonly]:focus {
    border-color: var(--border-light);
    box-shadow: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Input dengan prefix */
.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    z-index: 1;
}

.input-with-prefix input {
    padding-left: 40px;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-online {
    background: rgba(34, 197, 94, 0.1);
    color: rgb(21, 128, 61);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-offline {
    background: rgba(239, 68, 68, 0.1);
    color: rgb(185, 28, 28);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-pending {
    background: rgba(253, 224, 71, 0.1);
    color: rgb(161, 98, 7);
    border: 1px solid rgba(253, 224, 71, 0.2);
}

.status-overdue {
    background: rgba(239, 68, 68, 0.1);
    color: rgb(185, 28, 28);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-cancelled {
    background: rgba(156, 163, 175, 0.1);
    color: rgb(107, 114, 128);
    border: 1px solid rgba(156, 163, 175, 0.2);
}

/* ===== ACTION BUTTONS ===== */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-action-small {
    padding: 0.25rem 0.5rem;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
}

.btn-action-small:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-danger {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* ===== INVOICE SPECIFIC STYLES ===== */
.invoice-items-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--secondary-bg);
}

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

.section-header h5 {
    margin: 0;
    color: var(--text-primary);
}

.invoice-items-header {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--primary-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.invoice-items-header .form-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.invoice-item {
    margin-bottom: 0.75rem;
    padding: 1rem;
    background: var(--primary-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.invoice-item .form-row {
    margin-bottom: 0;
    align-items: center;
}

.invoice-item .item-total {
    background: var(--secondary-bg);
    font-weight: 600;
    color: var(--text-primary);
}

/* Remove button styling */
.remove-invoice-item {
    background: #dc2626;
    border: none;
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: var(--transition);
}

.remove-invoice-item:hover {
    background: #b91c1c;
}

/* Add item button */
#addInvoiceItem {
    background: var(--text-primary);
    border: none;
    border-radius: var(--radius);
    color: white;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

#addInvoiceItem:hover {
    background: var(--text-secondary);
}

/* ===== INVOICE TOTALS - FIXED STYLING ===== */
.invoice-totals {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--primary-bg);
    border-radius: var(--radius);
    border: 2px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--secondary-bg);
    border-radius: var(--radius);
}

.total-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.total-row label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    flex: 1;
}

.total-display {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    min-width: 150px;
    text-align: right;
}

/* Input styling untuk totals - PERBAIKAN */
.total-row .input-with-prefix {
    display: flex;
    align-items: center;
    min-width: 200px;
    justify-content: flex-end;
}

.total-row .input-with-prefix input {
    background: var(--primary-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem 1rem 0.5rem 2rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: right;
    min-width: 150px;
    box-shadow: var(--shadow-sm);
}

.total-row .input-with-prefix input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.total-row .input-prefix {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    z-index: 1;
}

/* Grand Total Styling */
.total-row.grand-total {
    background: var(--accent-color);
    margin: 1rem 0 0 0;
    padding: 1rem;
    border: 2px solid var(--accent-color);
    border-radius: var(--radius);
}

.total-row.grand-total label {
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
}

.total-row.grand-total .input-with-prefix input {
    background: rgba(255, 255, 255, 0.9);
    border-color: white;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.total-row.grand-total .input-prefix {
    color: var(--text-primary);
    font-weight: 700;
}

/* Hover effects untuk totals */
.total-row:hover {
    background: var(--secondary-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

/* Totals dengan prefix */
.totals-input-with-prefix {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 150px;
}

.totals-prefix {
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 4px;
}

.totals-value {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 100px;
    text-align: right;
}

/* ===== MAINTENANCE CONTROLS ===== */
.maintenance-controls {
    background: var(--primary-bg);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    max-width: 600px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .admin-header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .admin-container {
        padding: 0 1rem;
    }

    .admin-tabs {
        flex-direction: column;
    }

    .tab-button {
        justify-content: center;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }

    .overview-stats {
        grid-template-columns: 1fr;
    }

    .create-forms {
        grid-template-columns: 1fr;
    }

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

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

    .admin-table {
        min-width: 800px;
    }

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

    /* Invoice responsive */
    .invoice-item .form-row {
        flex-direction: column;
    }
    
    .invoice-item .form-group {
        margin-bottom: 0.5rem;
    }
    
    .total-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .total-row .input-with-prefix {
        width: 100%;
        justify-content: flex-start;
        min-width: auto;
    }
    
    .total-row .input-with-prefix input {
        min-width: 100%;
        text-align: left;
    }
    
    .total-row label {
        margin-bottom: 0.25rem;
    }

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

/* Print styles for invoices */
@media print {
    .admin-header,
    .admin-tabs,
    .btn-action {
        display: none !important;
    }
    
    .admin-main {
        padding: 0;
    }
    
    .invoice-totals,
    .invoice-items-section {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .total-row .input-with-prefix input {
        background: transparent;
        border: 1px solid #000;
    }
}