/* ==========================================
   KRISHNA ENTERPRISES ADMIN DASHBOARD STYLES
   Modern, Clean, Professional Design
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #0B1C39;
    --accent-orange: #FF6B35;
    --success-green: #10B981;
    --danger-red: #EF4444;
    --warning-yellow: #F59E0B;
    --purple: #8B5CF6;

    --bg-light: #F9FAFB;
    --bg-white: #FFFFFF;
    --border-color: #E5E7EB;
    --text-dark: #111827;
    --text-gray: #6B7280;
    --text-light: #9CA3AF;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--bg-light);
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1a3a5c 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--primary-blue);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-gray);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 13px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.error-message {
    background: #FEE2E2;
    color: var(--danger-red);
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border-left: 3px solid var(--danger-red);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--accent-orange);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    background: #e55a2b;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-gray);
    font-size: 12px;
}

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.admin-header {
    background: white;
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 20px;
    color: var(--primary-blue);
}

.admin-badge {
    background: var(--accent-orange);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-email {
    color: var(--text-gray);
    font-size: 13px;
}

.btn-logout {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-dark);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-logout:hover {
    background: var(--bg-light);
    border-color: var(--danger-red);
    color: var(--danger-red);
}

.dashboard-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.sidebar-nav {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-gray);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item i {
    width: 20px;
    font-size: 16px;
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.nav-item.active {
    background: #FEF3F0;
    color: var(--accent-orange);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.tab-content {
    display: none;
}

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

.tab-content h2 {
    font-size: 24px;
    color: var(--primary-blue);
    margin-bottom: 24px;
}

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

/* ==================== STATS CARDS ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-icon.blue {
    background: #3B82F6;
}

.stat-icon.green {
    background: var(--success-green);
}

.stat-icon.orange {
    background: var(--accent-orange);
}

.stat-icon.purple {
    background: var(--purple);
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-gray);
    font-size: 14px;
}

/* ==================== RECENT LEADS ==================== */
.recent-leads {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.recent-leads h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--primary-blue);
}

.leads-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lead-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 6px;
}

.lead-info {
    display: flex;
    flex-direction: column;
}

.lead-info strong {
    color: var(--text-dark);
    font-size: 14px;
}

.lead-info span {
    color: var(--text-gray);
    font-size: 12px;
}

.lead-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.service-tag,
.date-tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.service-tag {
    background: #DBEAFE;
    color: #1E40AF;
}

.date-tag {
    background: #F3F4F6;
    color: var(--text-gray);
}

/* ==================== FILTERS BAR ==================== */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-orange);
}

.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

/* ==================== DATA TABLE ==================== */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

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

.data-table thead {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-dark);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-dark);
}

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

.status-select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.btn-view {
    padding: 6px 12px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-view:hover {
    background: #1a3a5c;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--accent-orange);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #e55a2b;
}

.loading-row,
.empty-row,
.error-row {
    text-align: center;
    padding: 40px !important;
    color: var(--text-gray);
}

.error-row {
    color: var(--danger-red);
}

/* Date cell styling - Desktop */
.date-cell .mobile-date {
    display: none;
}

.date-cell .desktop-date {
    display: inline;
}

/* ==================== SECURITY CONTROLS ==================== */
.security-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 32px;
}

.control-card {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.control-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent-orange);
    transform: translateY(-1px);
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-header h3 {
    font-size: 16px;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.control-header p {
    font-size: 13px;
    color: var(--text-gray);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: var(--success-green);
}

input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

.security-metrics {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.security-metrics h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--primary-blue);
}

.metric-card {
    text-align: center;
    padding: 24px;
    background: var(--bg-light);
    border-radius: 8px;
}

.metric-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-orange);
    line-height: 1;
    margin-bottom: 8px;
}

.metric-label {
    color: var(--text-gray);
    font-size: 14px;
}

.rate-warning {
    margin-top: 16px;
    padding: 12px;
    background: #FEF3C7;
    border-left: 3px solid var(--warning-yellow);
    border-radius: 4px;
    color: #92400E;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== SETTINGS ==================== */
.settings-section {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.settings-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--primary-blue);
}

.link-grid {
    display: grid;
    gap: 12px;
}

.link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    transition: all 0.2s;
}

.link-card:hover {
    background: white;
    border-color: var(--accent-orange);
    box-shadow: var(--shadow-sm);
}

.link-card i:first-child {
    color: var(--accent-orange);
    font-size: 20px;
}

.link-card i:last-child {
    color: var(--text-light);
    font-size: 14px;
}

.btn-danger {
    padding: 10px 20px;
    background: var(--danger-red);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-danger:hover {
    background: #DC2626;
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    color: var(--primary-blue);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-gray);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 24px;
}

.lead-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bg-light);
}

.detail-row strong {
    color: var(--text-gray);
    font-weight: 500;
}

.detail-row span {
    color: var(--text-dark);
    text-align: right;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-new {
    background: #DBEAFE;
    color: #1E40AF;
}

.status-contacted {
    background: #FEF3C7;
    color: #92400E;
}

.status-closed {
    background: #D1FAE5;
    color: #065F46;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {

    /* Prevent horizontal scrolling */
    body {
        overflow-x: hidden;
    }

    /* Header mobile fixes */
    .admin-header {
        height: auto;
        min-height: 64px;
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-left {
        flex: 1 1 auto;
        min-width: 0;
        gap: 8px;
    }

    .header-left h1 {
        font-size: 16px;
        line-height: 1.3;
        word-wrap: break-word;
        max-width: 150px;
    }

    .admin-badge {
        display: none;
    }

    .header-right {
        flex: 0 0 auto;
        gap: 8px;
        align-items: center;
    }

    .user-email {
        font-size: 11px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .btn-logout {
        padding: 6px 10px;
        font-size: 11px;
        gap: 4px;
        white-space: nowrap;
    }

    .btn-logout i {
        font-size: 12px;
    }

    /* Dashboard container */
    .dashboard-container {
        flex-direction: column;
        width: 100%;
        max-width: 100%;
    }

    /* Sidebar navigation */
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 12px 16px;
        gap: 8px;
        justify-content: center;
        -webkit-overflow-scrolling: touch;
    }

    .nav-item {
        flex: 0 0 auto;
        padding: 10px 12px;
        min-width: 48px;
        justify-content: center;
    }

    .nav-item span {
        display: none;
    }

    .nav-item i {
        font-size: 18px;
        margin: 0;
    }

    /* Main content area */
    .main-content {
        padding: 16px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .tab-content h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }

    /* Stats grid - full width with consistent padding */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 20px;
        width: 100%;
        padding: 0;
    }

    .stat-card {
        width: 100%;
        padding: 16px;
        margin: 0;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .stat-info h3 {
        font-size: 24px;
    }

    .stat-info p {
        font-size: 13px;
    }

    /* Recent Leads - full width with same padding */
    .recent-leads {
        width: 100%;
        padding: 16px;
        margin: 0;
    }

    .recent-leads h3 {
        font-size: 15px;
        margin-bottom: 12px;
    }

    .lead-preview-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px;
    }

    .lead-meta {
        width: 100%;
        justify-content: flex-start;
    }

    /* Filters bar */
    .filters-bar {
        flex-direction: column;
        gap: 8px;
    }

    .search-input,
    .filter-select {
        width: 100%;
    }

    /* Table container */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

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

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 12px;
    }

    /* Date column mobile formatting - 3 line layout */
    .date-cell {
        min-width: 85px !important;
        padding: 12px 10px !important;
        vertical-align: top;
        line-height: 1;
    }

    .date-cell .desktop-date {
        display: none;
    }

    .date-cell .mobile-date {
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .date-cell .date-line {
        display: block;
        font-size: 11px;
        line-height: 1.5;
        color: var(--text-dark);
        white-space: nowrap;
    }

    .date-cell .date-line:first-child {
        font-weight: 500;
    }

    .date-cell .date-line:last-child {
        color: var(--text-gray);
        font-size: 10px;
    }

    /* Tab header */
    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

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

    /* Security controls */
    .security-grid {
        gap: 12px;
    }

    .control-card {
        padding: 16px;
    }

    .control-header h3 {
        font-size: 15px;
    }

    .control-header p {
        font-size: 12px;
    }

    /* Security metrics */
    .security-metrics {
        padding: 16px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-value {
        font-size: 36px;
    }

    /* Settings */
    .settings-section {
        padding: 16px;
    }

    .link-card {
        padding: 12px;
        font-size: 13px;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .detail-row span {
        text-align: left;
    }
}

/* ==================== PASSWORD TOGGLE ==================== */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
    /* Space for the button */
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--primary-blue);
}

.password-toggle:focus {
    outline: none;
    color: var(--accent-orange);
}