/* Theme System CSS */
:root {
    --primary-color: #7c3aed;
    --primary-hover: #6d28d9;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --white: #ffffff;
    --form-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-text: #1f2937;
    --input-placeholder: #9ca3af;
    --label-color: #374151;
    --heading-color: #1f2937;
    --card-bg: #ffffff;
    --table-bg: #ffffff;
    --table-header-bg: #f9fafb;
    --sidebar-width: 320px;
}

[data-theme="dark"] {
    --primary-color: #a855f7;
    --primary-hover: #9333ea;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border-color: #374151;
    --bg-light: #1f2937;
    --white: #111827;
    --form-bg: #1f2937;
    --input-bg: #374151;
    --input-border: #4b5563;
    --input-text: #f9fafb;
    --input-placeholder: #9ca3af;
    --label-color: #e5e7eb;
    --heading-color: #f9fafb;
    --card-bg: #1f2937;
    --table-bg: #1f2937;
    --table-header-bg: #374151;
}

body { 
    background: var(--white);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

/* Form Styling */
.form-control, .form-select, .form-textarea, textarea, select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="tel"], input[type="file"] {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--input-text) !important;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus, .form-textarea:focus, textarea:focus, select:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="number"]:focus, input[type="date"]:focus, input[type="tel"]:focus {
    background: var(--input-bg) !important;
    border-color: var(--primary-color) !important;
    color: var(--input-text) !important;
    box-shadow: 0 0 0 0.2rem rgba(168, 85, 247, 0.25) !important;
}

.form-control::placeholder, .form-select::placeholder, textarea::placeholder, input::placeholder {
    color: var(--input-placeholder) !important;
}

.form-label, label {
    color: var(--label-color) !important;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-text {
    color: var(--text-secondary) !important;
}

/* Input Group Styling */
.input-group-text {
    background: var(--table-header-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--text-secondary) !important;
}

/* Form Validation Styling */
.form-control.is-valid {
    border-color: #4ade80 !important;
    box-shadow: 0 0 0 0.2rem rgba(74, 222, 128, 0.25) !important;
}

.form-control.is-invalid {
    border-color: #f87171 !important;
    box-shadow: 0 0 0 0.2rem rgba(248, 113, 113, 0.25) !important;
}

.valid-feedback {
    color: #4ade80 !important;
}

.invalid-feedback {
    color: #f87171 !important;
}

/* Additional Form Styling */
.form-section {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-section h5 {
    color: var(--heading-color) !important;
    margin-bottom: 1rem;
    font-weight: 600;
}

fieldset {
    border: 1px solid var(--border-color) !important;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

legend {
    color: var(--heading-color) !important;
    font-weight: 600;
    padding: 0 0.5rem;
}

/* Checkbox and Radio Styling */
.form-check-input {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
}

.form-check-input:checked {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.form-check-label {
    color: var(--text-primary) !important;
}

/* File Input Styling */
.form-control[type="file"]::file-selector-button {
    background: var(--table-header-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--text-primary) !important;
}

/* Card and Container Styling */
.card {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.card-header {
    background: var(--table-header-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.card-body {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

/* Heading Styling */
h1, h2, h3, h4, h5, h6 {
    color: var(--heading-color) !important;
}

/* Button Styling */
.btn-primary {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--white) !important;
}

.btn-primary:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-outline-primary:hover {
    background: var(--primary-color) !important;
    color: var(--white) !important;
}

.btn-outline-secondary {
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

.btn-outline-secondary:hover {
    background: var(--bg-light) !important;
    color: var(--text-primary) !important;
}

.btn-outline-danger {
    color: #f87171 !important;
    border-color: #f87171 !important;
}

.btn-outline-danger:hover {
    background: #f87171 !important;
    color: var(--white) !important;
}

.btn-success {
    background: #4ade80 !important;
    border-color: #4ade80 !important;
    color: var(--white) !important;
}

.btn-success:hover {
    background: #22c55e !important;
    border-color: #22c55e !important;
}

/* Table Styling */
.table {
    color: var(--text-primary) !important;
}

.table th {
    background: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table td {
    background: var(--table-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Alert Styling */
.alert {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1) !important;
    border-color: rgba(34, 197, 94, 0.3) !important;
    color: #4ade80 !important;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #f87171 !important;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
    color: #fbbf24 !important;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    color: #60a5fa !important;
}

/* Modal Styling */
.modal-content {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
}

.modal-header {
    background: var(--table-header-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.modal-body {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

.modal-footer {
    background: var(--card-bg) !important;
    border-top: 1px solid var(--border-color) !important;
}

/* Dropdown Styling */
.dropdown-menu {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
}

.dropdown-item {
    color: var(--text-primary) !important;
}

.dropdown-item:hover {
    background: var(--bg-light) !important;
    color: var(--text-primary) !important;
}

/* Badge Styling */
.badge {
    background: var(--bg-light) !important;
    color: var(--text-primary) !important;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
}

.badge-invoice {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

.badge-nda {
    background: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
}

/* Text Colors */
.text-muted {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: #4ade80 !important;
}

.text-danger {
    color: #f87171 !important;
}

.text-warning {
    color: #fbbf24 !important;
}

.text-info {
    color: #60a5fa !important;
}

/* Spinner and Loading States */
.spinner-border {
    color: var(--primary-color) !important;
}

.spinner-border-sm {
    color: var(--text-secondary) !important;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

/* Fixed Theme Toggle for Forms */
.theme-toggle-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Dashboard Specific Styles */
.dashboard-container {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    background: var(--bg-light);
    transition: all 0.3s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

.header {
    background: var(--white);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-menu {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.menu-btn {
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-btn:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    text-decoration: none;
}

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

.content-area {
    padding: 2rem;
    transition: all 0.3s ease;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.document-table {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.3s ease;
}

.table {
    margin-bottom: 0;
}

.table th {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 1rem;
    transition: all 0.3s ease;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.table tr:last-child td {
    border-bottom: none;
}

.chat-sidebar {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.chat-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-header h5 {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.chat-header small {
    color: var(--text-secondary);
}

.chat-header .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-color: var(--border-color);
    color: var(--text-secondary);
    background: var(--white);
    transition: all 0.2s ease;
}

.chat-header .btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-light);
}

.chat-area {
    flex: 1;
    background: var(--bg-light);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    overflow-y: auto;
    max-height: 400px;
    transition: all 0.3s ease;
}

.chat-message {
    margin-bottom: 1rem;
}

.chat-message.user {
    text-align: right;
}

.chat-message.ai {
    text-align: left;
}

.chat-bubble {
    display: inline-block;
    max-width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.chat-bubble.user {
    background: var(--primary-color);
    color: var(--white);
}

.chat-bubble.ai {
    background: #f8f9fa;
    color: #222;
    border: 1px solid #ccc;
}

.chat-input {
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.75rem;
    width: 100%;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.sidebar-toggle {
    display: none;
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }
    
    .show-sidebar-btn {
        left: 10px;
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .header-menu {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .menu-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .content-area {
        padding: 1rem;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .header {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 1.25rem;
    }
    
    .header-menu {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin-top: 1rem;
    }
    
    .menu-btn {
        justify-content: center;
    }
    
    .content-area {
        padding: 0.75rem;
    }
    
    .row {
        margin: 0;
    }
    
    .col-lg-6 {
        padding: 0;
        margin-bottom: 1rem;
    }
}

/* Form Page Specific Styles */
.invoice-preview, .nda-preview { 
    background: var(--card-bg) !important; 
    border-radius: 12px; 
    box-shadow: 0 2px 16px rgba(0,0,0,0.07); 
    padding: 32px; 
    min-height: 600px; 
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.invoice-logo { max-width: 120px; max-height: 80px; }
.invoice-table th, .invoice-table td { vertical-align: middle; }
.invoice-title { font-size: 2rem; font-weight: bold; letter-spacing: 2px; color: var(--heading-color) !important; }
.invoice-meta { font-size: 1rem; color: var(--text-secondary) !important; }
.invoice-total { font-size: 1.2rem; font-weight: bold; color: var(--heading-color) !important; }
.form-section-title { 
    font-size: 1.1rem; 
    font-weight: 500; 
    margin-top: 1.5rem; 
    color: var(--heading-color) !important;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.nda-title { 
    font-size: 2rem; 
    font-weight: bold; 
    letter-spacing: 2px; 
    text-align: center; 
    color: var(--heading-color) !important;
}

.nda-section-title { 
    font-weight: 600; 
    margin-top: 1.5rem; 
    color: var(--heading-color) !important;
}

.streaming-cursor { 
    display: inline-block; 
    width: 10px; 
    background: var(--text-primary) !important; 
    height: 1.2em; 
    animation: blink 1s steps(1) infinite; 
    vertical-align: middle; 
}

.is-placeholder {
    color: var(--text-secondary) !important;
    font-style: italic;
    opacity: 0.8;
}

@keyframes blink { 
    50% { 
        opacity: 0; 
    } 
}

.show-sidebar-btn {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    border: none;
    color: var(--white);
    font-size: 1.2rem;
    padding: 0.75rem;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 999;
    display: none;
    width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
}

.show-sidebar-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

.show-sidebar-btn.visible {
    display: flex;
}

/* Show dropdown on hover for header menu (desktop only) */
@media (min-width: 992px) {
  .header .dropdown:hover .dropdown-menu {
    display: block;
    margin-top: 0;
  }
  .header .dropdown .dropdown-toggle[aria-expanded="true"] {
    /* Optional: keep active style when open */
  }
}

/* Enhanced Header Styles */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Profile Button Styles */
.profile-btn {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem !important;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.9rem !important;
    color: var(--text-primary) !important;
    text-decoration: none;
}

.profile-btn:hover {
    background: var(--bg-light) !important;
    color: var(--primary-color) !important;
}

.profile-btn i {
    font-size: 1.2rem;
}

/* Dropdown Menu Enhancements */
.dropdown-menu-scrollable {
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-header {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

/* Mobile Navigation Styles */
.mobile-nav {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
}

.mobile-menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    font-weight: 500;
    min-height: 80px;
}

.mobile-menu-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    text-decoration: none;
}

.mobile-menu-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.mobile-menu-btn.upgrade {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: var(--white);
    border-color: #f59e0b;
}

.mobile-menu-btn.upgrade:hover {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #d97706;
}

.mobile-menu-btn i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Upgrade Button Styles */
.upgrade-btn {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    border: none !important;
    color: var(--white) !important;
    font-weight: 500;
    transition: all 0.2s ease;
}

.upgrade-btn:hover {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: var(--white) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

/* Responsive Improvements */
@media (max-width: 991px) {
    .header-menu {
        display: none !important;
    }
    
    .sidebar-toggle {
        display: block !important;
    }
}

@media (max-width: 576px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .mobile-menu-btn {
        min-height: 70px;
        font-size: 0.7rem;
    }
    
    .mobile-menu-btn i {
        font-size: 1.25rem;
    }
    
    .profile-btn span {
        display: none !important;
    }
}

/* Theme Toggle Enhancement */
.theme-toggle {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    transform: scale(1.05);
} 