/**
 * Energy Comparison Tool - Main Stylesheet
 */

/* ========== Variables ========== */
:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --sidebar-width: 260px;
}

/* ========== Global Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-color);
    background-color: #fafafa;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

.container-fluid {
    padding: 0 2rem;
}

/* ========== Sidebar ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-item {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.9);
    transition: all 0.2s ease;
    cursor: pointer;
}

.menu-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.menu-item.active {
    background: rgba(255,255,255,0.15);
    border-left: 3px solid white;
}

.menu-item i {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

/* ========== Main Content ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 2rem;
}

.topbar {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin: -2rem -2rem 2rem -2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-title h4 {
    margin: 0;
    color: var(--dark-color);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    display: block;
}

.user-role {
    font-size: 0.875rem;
    color: #6b7280;
    text-transform: uppercase;
}

.btn-logout {
    padding: 0.5rem 1rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: #dc2626;
}

/* ========== Cards ========== */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h5 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.plans-tool-cards > [class*="col-"] > .card {
    margin-bottom: 0;
}

.plans-tool-cards .card-body .form-text {
    word-break: break-word;
}

.plans-tool-cards #discover-result,
.plans-tool-cards #import-one-result,
.plans-tool-cards #import-pdf-result {
    min-height: 0;
}

.plans-tool-cards #discover-result .alert:last-child,
.plans-tool-cards #import-one-result .alert:last-child,
.plans-tool-cards #import-pdf-result .alert:last-child {
    margin-bottom: 0;
}

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

.stat-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-icon.primary { background: rgba(37, 99, 235, 0.1); color: var(--primary-color); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success-color); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.stat-icon.info { background: rgba(6, 182, 212, 0.1); color: var(--info-color); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
}

.stat-label {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ========== Buttons ========== */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: #1d4ed8;
}

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

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

.btn-secondary {
    background: #6b7280;
    color: white;
}

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

/* ========== Forms ========== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    transition: border-color 0.2s ease;
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* ========== Tables ========== */
.table-responsive {
    overflow-x: auto;
}

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

.table thead {
    background: var(--light-color);
}

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

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--light-color);
}

/* ========== Badges ========== */
.badge {
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

/* ========== Alerts ========== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success-color);
    color: #065f46;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger-color);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning-color);
    color: #92400e;
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    border-left: 4px solid var(--info-color);
    color: #065666;
}

/* ========== Login Page ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

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

.login-header h2 {
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #6b7280;
}

/* ========== Rate Display ========== */
.rate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.rate-item {
    background: var(--light-color);
    padding: 1rem;
    border-radius: 0.375rem;
    text-align: center;
}

.rate-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.rate-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ========== Plan Comparison ========== */
.plan-card {
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.plan-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

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

.retailer-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark-color);
}

.plan-name {
    color: #6b7280;
    font-size: 0.9375rem;
}

.discount-badge {
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 1.125rem;
}

.plan-benefits {
    margin-top: 1rem;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.benefit-item i {
    color: var(--success-color);
}

.eligibility-repeater .eligibility-item {
    border-color: var(--border-color);
    background: #fff;
}

.eligibility-repeater .eligibility-item .card-body {
    padding: 1rem 1.25rem;
}

/* ========== Select2 (Bootstrap 5) ========== */
.select2-container--bootstrap-5 .select2-selection {
    min-height: calc(1.5em + 0.75rem + 2px);
    border-color: var(--border-color);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}

.list-filter-form .select2-container--bootstrap-5 .select2-selection {
    min-height: calc(1.5em + 0.5rem + 2px);
    font-size: 0.875rem;
}

.select2-container--bootstrap-5 .select2-dropdown {
    border-color: var(--border-color);
    z-index: 1060;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--primary-color);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ========== List filters & pagination ========== */
.list-toolbar .form-label {
    font-weight: 500;
    color: #6b7280;
}

.list-filter-form .btn {
    white-space: nowrap;
}

.list-pagination .pagination .page-link {
    color: var(--primary-color);
}

.list-pagination .pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.list-pagination .pagination .page-item.active .page-link:hover,
.list-pagination .pagination .page-item.active .page-link:focus {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

.list-pagination .pagination .page-item.disabled .page-link {
    color: #9ca3af;
}

.list-pagination .pagination-jump .pagination-page-input {
    width: 4.5rem;
    text-align: center;
}

.plan-pincode-list {
    max-height: 220px;
    overflow-y: auto;
}

.plan-contract-block h6 {
    color: #374151;
    font-weight: 600;
}

.plan-contract-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
}

.plan-subsection {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.plan-subsection:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.plan-section-title {
    margin-bottom: 0.75rem;
}

.plan-detail-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #4b5563;
}

.plan-info-panel {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    background: #fcfcfd;
}

.plan-tou-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.plan-tou-card {
    border: 1px solid #dbeafe;
    border-radius: 0.5rem;
    padding: 1rem;
    background: #f8fbff;
}

.plan-tou-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.plan-tou-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.plan-tou-rate {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.plan-schedule-table th,
.plan-schedule-table td {
    vertical-align: top;
}

.plan-schedule-table td:first-child {
    font-weight: 500;
    color: #1f2937;
}
