@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --dark-blue: #002668; /* Unified LegalEase Brand Blue */
  --primary-color: #F59E0B; /* LegalEase Amber */
  --secondary-color: #ffffff;
  --tertiary-color: #1F2937;
  --background-color: #F9FAFB;
  --border-color: #E5E7EB;
  --hover-bg-color: #F3F4F6;
  --buttons-bg: #002668;
  --buttons-hover-bg: #001a35;
  --danger-color: #EF4444;
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    background-color: var(--background-color);
}

body {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar (Original Design) ── */
.sidebar {
  width: 250px;
  background: var(--dark-blue);
  padding: 24px 16px;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  position: fixed;
  left: 0;
  top: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}

.sidebar-brand {
  text-align: center;
  padding: 10px 16px 20px 16px;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand span {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.sidebar h2 {
  margin-bottom: 32px;
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  padding-bottom: 16px;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.sidebar a {
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.75);
  padding: 12px 16px;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.95rem;
}

.sidebar a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  transform: translateX(4px);
}

.sidebar a.active {
  background-color: var(--primary-color);
  color: #FFFFFF;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

/* ── Main Content Area ── */
.main-content {
  flex: 1;
  margin-left: 250px;
  width: calc(100% - 250px);
  min-height: 100vh;
  padding: 20px;
  transition: all 0.3s ease;
}

/* ── Navbar (Original Brand Style) ── */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--dark-blue);
  border-bottom: 2px solid var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 900;
  color: #FFFFFF;
  margin: -20px -20px 25px -20px; /* Aligned with main-content padding */
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.menu-icon {
  font-size: 24px;
  cursor: pointer;
  color: #FFFFFF;
  display: none;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
}

.brand-legal { color: #FFFFFF !important; }
.brand-ease { color: #FFD700 !important; text-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }

/* Investor Module Green Theme Overrides */
.investor-module .sidebar { background: #14532d !important; }
.investor-module .navbar { background: #14532d !important; border-bottom-color: #198754 !important; }
.investor-module .customer-table th { background-color: #14532d !important; border-bottom: 2px solid #198754 !important; }
.investor-module .customer-action { background-color: #198754 !important; border: none !important; }
.investor-module .customer-action:hover { background-color: #14532d !important; box-shadow: 0 4px 12px rgba(25, 135, 84, 0.3) !important; }
.investor-module .stat-card { background: linear-gradient(135deg, #14532d 0%, #198754 100%) !important; box-shadow: 0 4px 12px rgba(20, 83, 45, 0.2) !important; }
.investor-module h3, .investor-module h4 { color: #14532d !important; border-bottom-color: #198754 !important; }
.investor-module .badge { background: #198754 !important; }
.investor-module .pagination a { background-color: #14532d !important; border-color: #14532d !important; }
.investor-module .pagination a:hover { background-color: transparent !important; color: #14532d !important; }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-icon-btn { font-size: 1.2rem; cursor: pointer; opacity: 0.8; transition: opacity 0.2s; }
.nav-icon-btn:hover { opacity: 1; }

.navbar-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.2); }

.profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.profile-info { display: flex; flex-direction: column; }
.profile-name { font-weight: 600; font-size: 0.9rem; }
.profile-role { font-size: 0.75rem; opacity: 0.8; }

.profile:hover .dropdown {
  display: block;
  animation: slideDown 0.3s ease-out;
}

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

.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  width: 220px;
  z-index: 2000;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
  margin-top: 10px;
  color: var(--tertiary-color);
  padding: 8px 0;
}

.dropdown-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: #F9FAFB;
  margin-bottom: 8px;
}

.dropdown-header p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dropdown-header strong {
  display: block;
  font-size: 0.9rem;
  color: var(--dark-blue);
  font-weight: 700;
}

.dropdown a {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: var(--tertiary-color);
  text-decoration: none !important;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.dropdown a:hover {
  background-color: var(--hover-bg-color);
  color: var(--dark-blue);
  padding-left: 24px;
}

.dropdown-logout {
  color: #EF4444 !important;
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
  padding-top: 12px !important;
}

.dropdown-logout:hover {
  background-color: #FEF2F2 !important;
}

.dropdown a i {
  width: 20px;
  text-align: center;
  margin-right: 12px;
  font-size: 1rem;
  opacity: 0.7;
}

.dropdown a:hover i {
  opacity: 1;
}

/* ── Dashboard Header & Actions ── */
.dashboard-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
    flex-wrap: wrap;
}

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

/* ── Stat Card (RESTORED ORIGINAL BLUE GRADIENT) ── */
.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
  color: #ffffff;
  padding: 0 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
  min-width: 180px;
  height: 52px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(30, 58, 138, 0.25);
}

.stat-card-icon { font-size: 1.5rem; opacity: 0.9; }
.stat-card-body { display: flex; flex-direction: column; line-height: 1.2; }
.stat-card-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; opacity: 0.8; letter-spacing: 0.5px; }
.stat-card-value { font-size: 1.4rem; font-weight: 800; }

/* ── Top Search Bar (Original Style) ── */
.top-search-bar {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 0 6px 0 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.2s ease;
    max-width: 280px;
    width: 100%;
    height: 52px;
}

.top-search-bar:hover { border-color: var(--primary-color); }
.top-search-bar input { border: none !important; outline: none; width: 100%; font-size: 0.9rem; font-weight: 500; color: var(--tertiary-color); }
.top-search-bar button {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Containers ── */
.form-container, .table-container {
    background: #ffffff;
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
}

.form-container .customer-action {
    min-width: 220px;
    margin-top: 0;
}

/* ── Table Search Section ── */
.search-container {
    margin-bottom: 25px;
    padding: 5px 0;
}

.search-container form {
    display: flex;
    gap: 12px;
    max-width: 700px;
    width: 100%;
}

#searchInput {
    flex: 1;
    padding: 12px 20px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    transition: all 0.2s ease;
    background: #ffffff;
}

#searchInput:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
    background: #fff;
}

.search-button {
    background-color: var(--dark-blue) !important;
    color: #ffffff !important;
    padding: 0 28px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 48px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.search-button:hover {
    background-color: var(--primary-color) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

/* ── Customer Table (RESTORED DARK BLUE HEADER) ── */
.customer-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px; /* Forces horizontal scroll on smaller screens */
}

.customer-table th {
  background-color: var(--dark-blue);
  color: #ffffff;
  padding: 15px 20px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom: 2px solid var(--primary-color);
  white-space: nowrap;
}

.customer-table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--tertiary-color);
  vertical-align: middle;
}

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

/* ── Form Restoration (Original Design) ── */
.form-container label, .modal-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark-blue);
    margin-top: 15px;
}

.form-container input[type="text"],
.form-container input[type="email"],
.form-container input[type="password"],
.form-container input[type="number"],
.form-container input[type="date"],
.form-container select,
.form-container textarea,
.modal-content input,
.modal-content select {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--tertiary-color);
    background-color: #ffffff;
    transition: all 0.2s ease;
    outline: none;
}

.form-container input:focus, .form-container select:focus, .modal-content input:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

.form-container h3 {
    color: var(--dark-blue);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    display: inline-block;
}

/* Services Checkbox Styling */
.services-input {
    margin: 20px 0;
    padding: 18px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.services-header {
    font-weight: 700 !important;
    color: var(--dark-blue);
    font-size: 0.95rem;
    margin-top: 0 !important;
    margin-bottom: 12px !important;
    display: block;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.service-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 550;
    color: var(--tertiary-color);
    background: #ffffff;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    user-select: none;
    margin-top: 0 !important;
}

.service-checkbox-label:hover {
    border-color: var(--primary-color);
    background: var(--hover-bg-color);
}

.services-input input[type="checkbox"] {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    cursor: pointer;
    transform: scale(1.2);
    flex-shrink: 0;
}

/* ── Landscape Modal UI Enhancements ── */
.modal-content.modal-xl {
    max-width: 1100px;
    width: 95%;
    margin: 30px auto;
}

/* Vertical Checklist Styles (Bootstrap-like utilities) */
.services-list-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.services-list-vertical .form-check {
    display: flex;
    align-items: center;
}

.services-list-vertical .form-check-input {
    margin: 0 !important;
    width: 18px !important;
    height: 18px !important;
    cursor: pointer;
    flex-shrink: 0;
}

.services-list-vertical .form-check-label {
    margin: 0 0 0 10px !important;
    font-size: 0.9rem;
    font-weight: 550;
    color: var(--tertiary-color);
    cursor: pointer;
}

/* Column form grid styles for landscape Edit Customer modal */
.edit-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
}

.edit-form-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.edit-form-col label {
    margin-top: 10px !important;
    margin-bottom: 6px !important;
}

.edit-form-col select {
    margin-top: 0 !important;
}

/* Responsiveness for mobile screens */
@media (max-width: 768px) {
    .edit-form-row {
        flex-direction: column;
        gap: 10px;
    }
}

/* ── Buttons (Original Styles) ── */
.customer-action {
    background-color: #4A90E2;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.customer-action:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-edit { background: transparent; border: 1.5px solid #4A90E2; color: #4A90E2; padding: 6px 15px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-edit:hover { background: #4A90E2; color: white; }

.btn-delete { background: transparent; border: 1.5px solid #EF4444; color: #EF4444; padding: 6px 15px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-delete:hover { background: #EF4444; color: white; }

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    overflow-y: auto;
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 600px;
    margin: 50px auto;
    padding: 30px;
    border-radius: 16px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.close { position: absolute; top: 20px; right: 20px; font-size: 24px; cursor: pointer; opacity: 0.5; }
.close:hover { opacity: 1; }

/* ── Sidebar Overlay & Close (For Mobile) ── */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

.sidebar-close { display: none; color: #fff; font-size: 30px; position: absolute; top: 20px; right: 20px; cursor: pointer; }

/* ============================================================
   RESPONSIVE OVERRIDES (Carefully Scoped)
   ============================================================ */

@media (max-width: 992px) {
    .sidebar { left: -250px; }
    .sidebar.active { left: 0; }
    .sidebar-close { display: block; }
    .main-content { margin-left: 0; width: 100%; padding: 15px; }
    .navbar { margin: -15px -15px 25px -15px; width: calc(100% + 30px); }
    .menu-icon { display: block; }
    .stat-cards-container { grid-template-columns: repeat(2, 1fr); }
    .dashboard-header-row { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }
}

@media (max-width: 768px) {
    .navbar-brand { font-size: 1.1rem; }
    .profile-info { display: none; }
    .stat-card { width: 100%; }
    .form-container, .table-container { padding: 15px; }
    .modal-content { width: 95%; margin: 20px auto; }
}

@media (max-width: 480px) {
    .navbar-brand { display: none; }
    .header-actions { flex-direction: column; align-items: stretch; }
    .top-search-bar { max-width: 100%; }
}

/* Ensure images and tables don't break layout */
img { max-width: 100%; height: auto; }

/* ── Global Table Responsiveness Fix ── */
.table-responsive {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 15px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
}

/* Ensure ALL tables inside responsive containers maintain a readable width */
.table-responsive table {
    min-width: 1000px !important; /* Force the scrollbar on small screens */
    width: 100% !important;
    border-collapse: collapse;
}

/* Global table cell behavior for better mobile readability */
.table-responsive th, 
.table-responsive td {
    white-space: nowrap; /* Prevent awkward text wrapping in data cells */
    padding: 12px 15px;
}

/* Fallback for tables NOT wrapped in .table-responsive (Surgical Display Hack) */
@media (max-width: 992px) {
    table:not(.no-responsive) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table:not(.no-responsive) thead,
    table:not(.no-responsive) tbody,
    table:not(.no-responsive) tr,
    table:not(.no-responsive) th,
    table:not(.no-responsive) td {
        /* display: block; */ /* We keep table structure but allow scrolling */
    }
}

/* ── Pagination Styles (NEW) ── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.pagination a {
    background-color: var(--dark-blue);
    color: #ffffff;
    padding: 8px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1.5px solid var(--dark-blue);
}

.pagination a:hover {
    background-color: transparent;
    color: var(--dark-blue);
}

.pagination span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--tertiary-color);
}

/* ── Button Polish ── */
.customer-action {
    background-color: var(--dark-blue) !important;
    color: #ffffff !important;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 38, 104, 0.2);
    display: inline-block;
    text-align: center;
    margin-top: 10px;
}

.customer-action:hover {
    background-color: var(--primary-color) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.3);
}

.customer-action:active {
    transform: translateY(0);
}
