/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Login Page Styles */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-form {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    max-width: 250px;
    height: auto;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-secondary {
    display: inline-block;
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.login-footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Subscription Page Styles */
.subscription-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.subscription-container {
    max-width: 800px;
    margin: 0 auto;
}

.subscription-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.subscription-content h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.subscription-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.subscription-content h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.info-section {
    margin-bottom: 40px;
}

.features-list {
    list-style: none;
    padding-left: 0;
}

.features-list li {
    padding: 10px 0;
    border-bottom: 1px solid #e1e5e9;
}

.features-list li:last-child {
    border-bottom: none;
}

.features-list strong {
    color: #667eea;
}

.registration-form {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.back-link {
    text-align: center;
    margin-top: 20px;
}

.back-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.back-link a:hover {
    text-decoration: underline;
}

/* Dashboard Styles */
.dashboard-page {
    background: #f8f9fa;
    min-height: 100vh;
}

.dashboard-header {
    background: white;
    padding: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dashboard-header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-logo {
    max-width: 200px;
    height: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info span {
    font-weight: 500;
    color: #333;
}

.logout-btn {
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

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

.dashboard-nav {
    background: #343a40;
    padding: 15px 0;
}

.dashboard-nav .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav-links {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.nav-links a {
    color: #adb5bd;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 0;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    border-bottom-color: #667eea;
}

/* Multi-office selector styles */
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.office-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
}

.office-selector-label {
    color: #adb5bd;
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.9em;
}

.office-dropdown {
    background: #495057;
    color: white;
    border: 1px solid #6c757d;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.9em;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.office-dropdown:hover {
    background: #5a6268;
    border-color: #667eea;
}

.office-dropdown:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

.office-dropdown option {
    background: #495057;
    color: white;
    padding: 5px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.85em;
}

/* Lab names in dropdown - bold and slightly larger */
.office-dropdown option.lab-option {
    font-weight: bold;
    font-size: 0.95em;
    padding-top: 8px;
    padding-bottom: 3px;
}

/* Office names in dropdown - normal weight with tree characters */
.office-dropdown option.office-option {
    font-weight: normal;
    padding-left: 10px;
}

/* Office context indicator styles */
.office-context-indicator {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 4px;
    padding: 10px 15px;
    margin-top: 15px;
    font-size: 0.9em;
}

.office-context-indicator strong {
    color: #1976d2;
}

.office-context-indicator small {
    display: block;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

.dashboard-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px 20px;
}

.page-title {
    margin-bottom: 30px;
}

.page-title h1 {
    color: #333;
    font-size: 2.2em;
    margin-bottom: 10px;
}

.page-title p {
    color: #666;
    font-size: 1.1em;
}

/* Form Styles */
.form-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.form-section h2 {
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e1e5e9;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.setting-item label {
    font-weight: 500;
    color: #333;
    cursor: pointer;
}

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

.toggle-switch input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

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

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

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

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

/* API Keys Display */
.api-key-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.api-key-item label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.api-key-value {
    font-family: 'Monaco', 'Consolas', monospace;
    background: #343a40;
    color: #f8f9fa;
    padding: 12px;
    border-radius: 4px;
    word-break: break-all;
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #667eea;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.copy-btn:hover {
    background: #5a6fd8;
}

/* Countries Selection */
.countries-section {
    margin-bottom: 25px;
}

.countries-section .setting-item {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.country-search-container {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.country-search {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.country-actions {
    display: flex;
    gap: 8px;
}

.btn-secondary.small {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
}

.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e1e5e9;
    padding: 15px;
    border-radius: 6px;
    background: #fafafa;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.country-item:hover {
    background-color: #f0f0f0;
}

.country-item input[type="checkbox"] {
    margin: 0;
}

.country-item label {
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-header .container {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .nav-links {
        justify-content: center;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-row .form-group {
        margin-bottom: 20px;
    }
    
    .dashboard-content {
        padding: 0 15px;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .countries-grid {
        grid-template-columns: 1fr;
        max-height: 250px;
    }
    
    .country-search-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .country-actions {
        justify-content: center;
    }
}

/* Markdown helper styling */
.markdown-helper {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 0.85em;
    line-height: 1.3;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.markdown-helper code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    white-space: nowrap;
}

.markdown-helper strong {
    color: #495057;
    margin-right: 4px;
}

.markdown-helper span:not(:first-child) {
    position: relative;
}

.markdown-helper span:not(:first-child):not(:last-child)::after {
    content: "•";
    margin-left: 8px;
    color: #6c757d;
    font-weight: normal;
}

/* Improved textarea styling */
textarea {
    font-family: 'Monaco', 'Consolas', 'SFMono-Regular', monospace;
    font-size: 14px;
    line-height: 1.5;
}

/* Form field improvements */
.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input[required] + label::after,
.form-group label[for] input[required]::after {
    content: " *";
    color: #dc3545;
}

/* Better spacing for form sections */
.form-section h2 {
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e1e5e9;
    color: #495057;
}

/* Workflow Settings Layout */
.workflow-settings {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.workflow-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

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

.workflow-header label {
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-size: 1.1em;
    margin: 0;
}

.workflow-description {
    margin-top: 8px;
}

.workflow-description p {
    margin: 0;
    color: #666;
    font-size: 0.95em;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .subscription-content {
        padding: 20px;
    }
    
    .login-form {
        padding: 30px 20px;
    }
    
    .page-title h1 {
        font-size: 1.8em;
    }
    
    .markdown-helper {
        font-size: 0.8em;
        padding: 6px 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Hierarchical Dashboard Navigation */
.nav-links {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

/* Base nav link styles */
.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    color: #666;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.nav-link.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.nav-icon {
    font-size: 1em;
}


/* Breadcrumb Navigation with Sub-Navigation */
.breadcrumb-nav {
    background: white;
    border-bottom: 1px solid #e1e5e9;
    padding: 12px 0;
}

.breadcrumb-nav .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.breadcrumb-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.breadcrumb a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb a:hover {
    color: #5a6fd8;
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #999;
    margin: 0 4px;
}

.breadcrumb-current {
    color: #333;
    font-weight: 500;
}

/* Sub-navigation */
.sub-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sub-nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1em;
    border-radius: 25px;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    transform: translateY(0);
}

.sub-nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.sub-nav-link:hover::before {
    left: 100%;
}

.sub-nav-link:hover {
    color: white;
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.sub-nav-link.active {
    color: #667eea;
    background: white;
    border-color: #667eea;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transform: translateY(-1px);
}

.sub-nav-link.active:hover {
    color: #5a67d8;
    background: #f8f9ff;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.4);
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-link {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .nav-icon {
        font-size: 0.9em;
    }
    
    .office-selector {
        min-width: auto;
        width: 100%;
        justify-content: center;
    }
    
    .office-dropdown {
        min-width: 250px;
        max-width: 300px;
    }
    
    .breadcrumb-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .sub-nav {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 10px;
    }
    
    .sub-nav-link {
        padding: 10px 16px;
        font-size: 0.9em;
        font-weight: 600;
        border-radius: 20px;
    }
}

/* Features Section Styles */
#features-container {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.features-row {
    flex-direction: row !important;
}

.feature-item {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto;
}

.feature-item input {
    width: 180px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

@media (max-width: 768px) {
    #features-container {
        flex-wrap: wrap;
    }

    .feature-item {
        flex: 1 1 calc(50% - 10px);
        min-width: 150px;
    }
}

.btn-remove-feature {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-remove-feature:hover {
    background: #c82333;
}

.feature-suggestions {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-top: 10px;
}

.feature-suggestions small {
    display: block;
    margin-bottom: 8px;
    color: #6c757d;
    font-weight: 500;
}

.btn-suggestion {
    display: inline-block;
    margin: 4px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-suggestion:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}