/* Admin Panel Specific Styles */

/* Navigation */
.admin-nav {
    background: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-nav .container {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.nav-link {
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.nav-link.active {
    color: var(--primary-color);
    background: var(--bg-color);
}

/* Admin Sections */
.admin-section {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Admin Management Styles */
.admin-list-container {
    margin-bottom: 2rem;
}

.admin-list-container h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.admins-list {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1rem;
}

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-item:last-child {
    margin-bottom: 0;
}

.admin-info {
    flex: 1;
}

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

.admin-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #4CAF50;
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.admin-badge.current {
    background: var(--primary-color);
}

.admin-badge.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-weight: 700;
}

.admin-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

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

.btn-remove {
    background: #f44336;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-remove:hover:not(:disabled) {
    background: #d32f2f;
    transform: translateY(-1px);
}

.btn-remove:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.admin-form {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.admin-form h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* Admin Form */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

@media (min-width: 768px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-group textarea {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Success Message */
.success-message {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message::before {
    content: "✓";
    font-size: 1.5rem;
    font-weight: bold;
}

/* Calculation Preview */
.calculation-preview {
    background: #ffffff;
    color: #212121;
    padding: 1.5rem;
    border-radius: 12px;
    margin: 1rem 0;
    border: 1px solid #e0e0e0;
}

.calculation-preview h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
    color: #2e7d32;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 768px) {
    .calc-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.calc-item {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #eeeeee;
}

.calc-label {
    display: block;
    font-size: 0.875rem;
    color: #616161;
    margin-bottom: 0.5rem;
}

.calc-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #212121;
}

/* Form Enhancements */
input[type="date"],
input[type="datetime-local"] {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input[type="date"]:focus,
input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Mobile Navigation */
@media (max-width: 640px) {
    .admin-nav .container {
        flex-wrap: wrap;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .nav-link {
        font-size: 0.8rem;
        padding: 0.6rem 0.75rem;
    }
    
    .backup-dropdown {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    .backup-dropdown-btn {
        width: 100%;
    }
    
    .language-switcher {
        order: 10;
        width: 100%;
    }
    
    .nav-user-section {
        order: 11;
        width: 100%;
    }
}

/* Loading State */
.btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Result Display */
.result-box {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1rem;
    border-left: 4px solid var(--success-color);
}

.result-box h3 {
    color: var(--success-color);
    margin-bottom: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.result-label {
    color: var(--text-secondary);
    font-weight: 500;
}

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

/* Highlight Important Fields */
.form-group label::after {
    content: " *";
    color: var(--danger-color);
    display: none;
}

.form-group input:required + .form-group label::after,
.form-group select:required + .form-group label::after {
    display: inline;
}

/* Query Results Styles */
.query-results {
    animation: fadeIn 0.4s ease-in;
}

.result-summary {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.customer-chits-list {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 12px;
}

.customer-chits-list h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.customer-chits-list table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.customer-chits-list thead {
    background: var(--primary-color);
    color: white;
}

.customer-chits-list th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.customer-chits-list td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.customer-chits-list tbody tr:last-child td {
    border-bottom: none;
}

.customer-chits-list tbody tr:hover {
    background: #f5f5f5;
}

/* Mobile Responsive for Query Results */
@media (max-width: 768px) {
    .result-summary > div {
        grid-template-columns: 1fr !important;
    }
    
    .customer-chits-list table {
        font-size: 0.875rem;
    }
    
    .customer-chits-list th,
    .customer-chits-list td {
        padding: 0.75rem 0.5rem;
    }
}

/* Backup & Import Dropdown */
.backup-dropdown {
    position: relative;
    display: inline-block;
}

.backup-dropdown-btn {
    background: linear-gradient(135deg, #43a047, #2e7d32) !important;
    color: white !important;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.backup-dropdown-btn:hover {
    background: linear-gradient(135deg, #388e3c, #1b5e20) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.backup-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1000;
    margin-top: 8px;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease;
}

.backup-dropdown-menu.show {
    display: block;
}

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

.backup-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
    text-align: left;
    transition: background 0.2s ease;
}

.backup-dropdown-item:hover {
    background: #f5f5f5;
}

.backup-dropdown-item:first-child {
    border-radius: 12px 12px 0 0;
}

.backup-dropdown-item:last-child {
    border-radius: 0 0 12px 12px;
}

.dropdown-icon {
    font-size: 1.1rem;
}

.backup-dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 0.25rem 0;
}

/* Mobile adjustments for dropdown */
@media (max-width: 768px) {
    .backup-dropdown-menu {
        right: auto;
        left: 0;
        min-width: 100%;
    }
}

/* Customer / Reports mode toggle (Add Customer | Edit | Add Chit) */
.customer-mode-toggle,
.reports-mode-toggle {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.customer-mode-toggle .mode-btn,
.reports-mode-toggle .mode-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.875rem 0.75rem;
    border: none;
    background: #e0e0e0;
    color: #666;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    box-sizing: border-box;
}

.customer-mode-toggle .mode-btn-icon,
.reports-mode-toggle .mode-btn-icon {
    font-size: 1.05rem;
    flex-shrink: 0;
}

.customer-mode-toggle .mode-btn.active {
    background: linear-gradient(135deg, #4caf50, #2e7d32);
    color: white;
}

@media (max-width: 720px) {
    /* Keep one unified segmented bar (same look as desktop), just denser */
    .customer-mode-toggle,
    .reports-mode-toggle {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow: hidden;
        gap: 0;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        background: #e0e0e0;
    }

    .customer-mode-toggle .mode-btn,
    .reports-mode-toggle .mode-btn {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        min-height: 3.25rem;
        border-radius: 0;
        padding: 0.65rem 0.35rem;
        font-size: 0.72rem;
        font-weight: 700;
        gap: 0.25rem;
        flex-direction: column;
        box-shadow: none;
        line-height: 1.15;
    }

    .customer-mode-toggle .mode-btn-icon,
    .reports-mode-toggle .mode-btn-icon {
        font-size: 1.15rem;
        line-height: 1;
    }

    .admin-section .card {
        padding: 1rem;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

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