:root {
  --primary-blue: #007AFF;
  --primary-purple: #5856D6;
  --secondary-bg: #F2F2F7;
  --text-color: #1C1C1E;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --radius-lg: 16px;
  --radius-md: 12px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-color);
  background-color: #f8fafc;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Page background for unauthenticated screens (e.g. Login) */
.auth-page {
  background-color: #f5f5f7;
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
  background-image:
    radial-gradient(at 40% 20%, rgba(0, 122, 255, 0.1) 0px, transparent 50%),
    radial-gradient(at 80% 0%, rgba(88, 86, 214, 0.1) 0px, transparent 50%),
    radial-gradient(at 0% 50%, rgba(0, 122, 255, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Glassmorphism Card */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-weight: 600;
  color: var(--primary-purple);
}

/* Navbar */
.navbar {
  background: rgba(255, 255, 255, 0.8) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: var(--shadow-sm);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1030;
}

.navbar-brand {
  font-weight: 700;
  color: var(--primary-blue) !important;
}

.nav-link {
  font-weight: 500;
  color: var(--text-color) !important;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--primary-blue) !important;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

/* Inputs */
.form-control {
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.form-control:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

/* Login Page Specifics */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

.login-title {
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-blue), var(--primary-purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin-bottom: 2rem;
}

/* Badges */
.badge {
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
}

.bg-success {
  background-color: #34C759 !important;
}

.bg-danger {
  background-color: #FF3B30 !important;
}

.bg-warning {
  background-color: #FFCC00 !important;
}

/* Footer Positioning */
.footer {
  position: relative !important;
  bottom: auto !important;
  width: 100%;
  min-height: 60px;
  background: #f8f9fa;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: auto;
  padding: 15px 0;
  white-space: normal !important;
  line-height: normal !important;
}

/* Enhanced Button Interactions */
.btn {
  transition: all 0.2s ease-in-out;
  border-radius: 8px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-outline-secondary:hover {
  background-color: #6c757d;
  border-color: #6c757d;
  color: white;
}

.btn-outline-primary:hover {
  background-color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.btn-outline-success:hover {
  background-color: #34C759;
  border-color: #34C759;
}

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

.btn-outline-warning:hover {
  background-color: #FFCC00;
  border-color: #FFCC00;
  color: #000;
}

/* Loading State for Buttons */
.btn.loading {
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Container Improvements */
.container-fluid {
  padding-left: 20px;
  padding-right: 20px;
}

.container {
  flex: 1; /* Allow main container to grow and push footer down */
}

main {
  margin-bottom: 20px;
}

/* Dropdown Enhancements */
.dropdown-menu {
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

.dropdown-item:hover {
  background-color: rgba(0, 122, 255, 0.1);
  color: var(--primary-blue);
}

/* Project Summary Page Specific */
.project-summary-content {
  margin-bottom: 40px; /* Extra space before footer */
}

.project-summary-content .card:last-child {
  margin-bottom: 60px; /* Ensure last card has enough space */
}

/* Page Bottom Spacing - Prevents footer overlap */
.page-content {
  margin-bottom: 80px; /* Extra space for pages with forms at bottom */
}

.review-page-content {
  margin-bottom: 120px; /* Extra space for review pages with action buttons */
}

/* Responsive Improvements */
@media (max-width: 768px) {
  body {
    padding-top: 70px;
    padding-bottom: 20px; /* Normal spacing on mobile */
  }
  
  .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  .card {
    margin-bottom: 20px;
  }
  
  .btn-group-vertical .btn {
    margin-bottom: 5px;
  }
  
  /* Mobile footer adjustments */
  .footer {
    height: 50px; /* Smaller footer on mobile */
  }
}

/* Notification Badge Styling */
.notification-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background-color: #dc3545 !important;
    color: white !important;
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 1.2rem;
    height: 1.2rem;
    line-height: 1.2rem;
    text-align: center;
    border-radius: 50%;
    padding: 0;
    z-index: 1050;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Layout Structure Grid */
.app-container {
    display: flex;
    min-height: 100vh;
    background-color: #f1f5f9; /* Warm Slate 100 background */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Sidebar Framework */
.app-sidebar {
    width: 270px;
    background-color: #0f172a; /* Slate 900 */
    color: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e293b;
    box-shadow: 4px 0 24px 0 rgba(15, 23, 42, 0.15);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: 70px;
    padding: 0 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff !important;
    text-decoration: none !important;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: opacity 0.2s;
}

.sidebar-brand:hover {
    opacity: 0.9;
    color: #ffffff !important;
}

.sidebar-brand i {
    font-size: 1.35rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

/* Custom Scrollbar for Sidebar */
.sidebar-body::-webkit-scrollbar {
    width: 4px;
}
.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-body::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

/* Group Headers */
.menu-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569; /* Slate 600 */
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 1.75rem 0 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.menu-group-label:first-of-type {
    margin-top: 0;
}

/* Vertical Menu Items */
.sidebar-menu-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.65rem 0.85rem;
    color: #94a3b8 !important; /* Slate 400 */
    border-radius: 8px;
    text-decoration: none !important;
    transition: all 0.2s ease-in-out;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    cursor: pointer !important;
    user-select: none;
}

.sidebar-menu-item:hover {
    background-color: rgba(30, 41, 59, 0.75); /* Slate 800 */
    color: #f8fafc !important; /* Slate 50 */
    padding-left: 1.1rem; /* Micro-interaction sliding */
}

/* Active State & indicator left bar */
.sidebar-menu-item.active {
    background-color: rgba(37, 99, 235, 0.15) !important; /* Soft transparent blue */
    color: #3b82f6 !important; /* Bright blue text */
    font-weight: 600;
}

.sidebar-menu-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3.5px;
    background-color: #3b82f6;
    border-radius: 0 4px 4px 0;
}

.sidebar-menu-item i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1.05rem;
    text-align: center;
    transition: transform 0.2s;
}

.sidebar-menu-item:hover i {
    transform: scale(1.1);
}

.sidebar-menu-item .badge {
    margin-left: auto;
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
    font-weight: 700;
}

/* ===== Sidebar: search, accordion groups, sub-labels ===== */
.sidebar-search {
    position: relative;
    margin: 0 0 1.1rem 0;
}

.sidebar-search-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: #64748b;
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    background-color: rgba(30, 41, 59, 0.6);
    border: 1px solid #1e293b;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.85rem;
    padding: 0.55rem 3.6rem 0.55rem 2.1rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.sidebar-search-input::placeholder {
    color: #64748b;
}

.sidebar-search-input:focus {
    border-color: #3b82f6;
    background-color: rgba(30, 41, 59, 0.9);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.sidebar-search-input::-webkit-search-cancel-button {
    filter: invert(0.6);
    cursor: pointer;
}

.sidebar-search-kbd {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.62rem;
    font-family: inherit;
    font-weight: 600;
    color: #64748b;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    pointer-events: none;
    transition: opacity 0.15s;
}

.sidebar-search-input:focus ~ .sidebar-search-kbd,
.sidebar-search-input:not(:placeholder-shown) ~ .sidebar-search-kbd {
    opacity: 0;
}

.sidebar-group {
    margin-bottom: 0.2rem;
}

.sidebar-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: transparent;
    border: 0;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    color: #cbd5e1; /* Slate 300 */
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-group-toggle:hover {
    background-color: rgba(30, 41, 59, 0.55);
    color: #f8fafc;
}

.sidebar-group-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.sidebar-group-icon {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    color: #64748b;
    transition: color 0.2s;
}

.sidebar-group.open > .sidebar-group-toggle .sidebar-group-icon,
.sidebar-group-toggle:hover .sidebar-group-icon {
    color: #3b82f6;
}

.sidebar-group-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-group-chevron {
    font-size: 0.65rem;
    color: #64748b;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-group.open > .sidebar-group-toggle .sidebar-group-chevron {
    transform: rotate(180deg);
}

/* Smooth height transition via grid rows (0fr -> 1fr) */
.sidebar-group-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-group.open > .sidebar-group-panel {
    grid-template-rows: 1fr;
}

.sidebar-group-inner {
    min-height: 0;
    overflow: hidden;
    visibility: hidden;
    padding-left: 0.6rem;
    margin-left: 0.85rem;
    border-left: 1px solid #1e293b;
    transition: visibility 0s linear 0.28s;
}

.sidebar-group.open > .sidebar-group-panel > .sidebar-group-inner {
    visibility: visible;
    padding-top: 0.2rem;
    padding-bottom: 0.4rem;
    transition: visibility 0s linear 0s;
}

.sidebar-group-inner .sidebar-menu-item {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
}

.sidebar-group-inner .sidebar-menu-item:hover {
    padding-left: 0.95rem;
}

.sidebar-group-inner .sidebar-menu-item i {
    font-size: 0.9rem;
    margin-right: 0.65rem;
}

.sidebar-menu.no-anim .sidebar-group-panel,
.sidebar-menu.no-anim .sidebar-group-inner,
.sidebar-menu.no-anim .sidebar-group-chevron,
.sidebar-menu.searching .sidebar-group-panel,
.sidebar-menu.searching .sidebar-group-inner {
    transition: none !important;
}

.sidebar-menu.searching .sidebar-group-toggle {
    cursor: default;
}

.sidebar-sublabel {
    font-size: 0.64rem;
    font-weight: 700;
    color: #475569; /* Slate 600 */
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 0.6rem 0.75rem 0.25rem;
    user-select: none;
}

.sidebar-group-inner > .sidebar-sublabel:first-child {
    padding-top: 0.3rem;
}

.sidebar-menu.searching .sidebar-sublabel,
.sidebar-menu .search-hidden {
    display: none !important;
}

.sidebar-search-empty {
    font-size: 0.82rem;
    color: #64748b;
    padding: 0.75rem;
    text-align: center;
}

.sidebar-search-empty[hidden] {
    display: none !important;
}

.sidebar-menu-item .badge.sidebar-live-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.45rem;
    color: #22c55e;
    background-color: rgba(34, 197, 94, 0.14);
    border: 1px solid rgba(34, 197, 94, 0.28);
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-group-panel,
    .sidebar-group-inner,
    .sidebar-group-chevron {
        transition: none !important;
    }
}

@media (hover: none) {
    .sidebar-search-kbd {
        display: none;
    }
}

/* Work Area pane */
.app-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header {
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.01);
}

.app-header h5 {
    color: #0f172a;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-body {
    flex-grow: 1;
    padding: 2.25rem;
    overflow-y: auto;
}

.sidebar-toggle {
    display: inline-block;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.1rem;
    color: #334155;
    padding: 0.5rem 0.65rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.sidebar-toggle:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

/* Sidebar Hide Logic on Desktop */
.app-container.sidebar-hidden .app-sidebar {
    margin-left: -270px !important;
}

.app-footer {
    background-color: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 1.25rem 2.5rem;
    color: #64748b;
}

/* Mobile responsive drawers */
@media (max-width: 991.98px) {
    .app-container.sidebar-hidden .app-sidebar,
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -270px;
        margin-left: 0 !important; /* Reset desktop hide logic for mobile */
        z-index: 1050;
    }
    
    .app-sidebar.show {
        left: 0 !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(4px);
        z-index: 1040;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .app-header {
        padding: 0 1.5rem;
    }
    
    .app-body {
        padding: 1.5rem;
    }
}

/* Zoho Live Status Indicator & Ticker */
.zoho-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: zohoPulse 2s infinite;
    flex-shrink: 0;
}

.zoho-live-dot.disconnected {
    background-color: #ef4444 !important;
    box-shadow: none !important;
    animation: none !important;
}

@keyframes zohoPulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}