/**
 * VesselDocs.ai - Maritime Document Verification System
 * Stylesheet - Professional Beige & Orange Theme
 */

/* ============================================
   CSS Variables - Beige & Orange Theme
   ============================================ */
:root {
    --primary-orange: #E67E22;
    --primary-orange-dark: #D35400;
    --primary-orange-light: #F39C12;
    --beige-50: #FDF8F3;
    --beige-100: #FAF3EB;
    --beige-200: #F5E6D3;
    --beige-300: #E8D4BC;
    --beige-400: #D4B896;
    --grey-500: #8B7355;
    --grey-600: #6B5A47;
    --grey-700: #4A3F35;
    --grey-800: #3D3329;
    --grey-900: #2C241C;
    --success-green: #27AE60;
    --success-light: #E8F8F0;
    --error-red: #C0392B;
    --error-light: #FDEDEC;
    --warning-orange: #F39C12;
    --warning-light: #FEF9E7;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(74, 63, 53, 0.08);
    --shadow-md: 0 4px 12px rgba(74, 63, 53, 0.12);
    --shadow-lg: 0 10px 25px rgba(74, 63, 53, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.25s ease;
}

/* ============================================
   Reset & Base Styles
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--beige-100);
    color: var(--grey-800);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    line-height: 1.3;
    color: var(--primary-orange);
}

/* ============================================
   Navigation
   ============================================ */
.navbar {
    background: var(--white);
    border-bottom: 3px solid var(--primary-orange);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-img {
    height: 50px;
    width: auto;
}

.logo-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-orange);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 28px;
}

.nav-links a {
    color: var(--grey-700);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--primary-orange);
}

.chatbot-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    color: var(--white);
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.chatbot-toggle:hover {
    background: linear-gradient(135deg, var(--primary-orange-light) 0%, var(--primary-orange) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.chatbot-toggle svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Main Content Layout
   ============================================ */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px;
    min-height: calc(100vh - 140px);
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Panel Styles
   ============================================ */
.reference-panel,
.verification-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--beige-300);
}

.panel-header {
    background: linear-gradient(135deg, var(--grey-800) 0%, var(--grey-700) 100%);
    color: var(--white);
    padding: 24px 28px;
    border-bottom: 4px solid var(--primary-orange);
}

.panel-header h2 {
    font-size: 1.4rem;
    margin-bottom: 6px;
    color: var(--white);
}

.panel-header p {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* ============================================
   Form Sections
   ============================================ */
.form-section {
    padding: 24px 28px;
    border-bottom: 1px solid var(--beige-200);
    background: var(--beige-50);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section:nth-child(even) {
    background: var(--white);
}

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

.section-header h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    color: var(--primary-orange);
}

.section-header svg {
    width: 24px;
    height: 24px;
    color: var(--primary-orange);
}

.save-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--beige-100);
    color: var(--primary-orange);
    border: 2px solid var(--primary-orange);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.save-btn:hover {
    background: var(--primary-orange);
    color: var(--white);
}

.save-btn svg {
    width: 18px;
    height: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--grey-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 14px;
    border: 2px solid var(--beige-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: var(--transition);
    font-family: inherit;
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 4px rgba(230, 126, 34, 0.15);
}

.form-group input::placeholder {
    color: var(--beige-400);
}

/* Custom Fields */
.custom-fields-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 18px;
}

.custom-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 14px;
    align-items: center;
}

.custom-field-row input {
    padding: 12px 14px;
    border: 2px solid var(--beige-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--white);
}

.custom-field-row input:focus {
    outline: none;
    border-color: var(--primary-orange);
}

.remove-custom-field {
    background: var(--error-light);
    color: var(--error-red);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.remove-custom-field:hover {
    background: var(--error-red);
    color: var(--white);
}

.remove-custom-field svg {
    width: 20px;
    height: 20px;
}

.add-field-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    color: var(--primary-orange);
    border: 2px dashed var(--primary-orange);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 18px;
}

.add-field-btn:hover {
    background: rgba(230, 126, 34, 0.08);
}

.add-field-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Upload Section
   ============================================ */
.upload-section {
    padding: 28px;
    background: var(--beige-50);
}

.upload-area {
    border: 3px dashed var(--beige-400);
    border-radius: var(--radius-lg);
    padding: 50px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-orange);
    background: rgba(230, 126, 34, 0.05);
}

.upload-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.upload-icon svg {
    width: 32px;
    height: 32px;
    color: var(--white);
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--grey-500);
}

/* Files List */
.files-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--beige-300);
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.file-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--grey-800);
}

.file-size {
    font-size: 0.8rem;
    color: var(--grey-500);
}

.remove-file {
    background: transparent;
    border: none;
    color: var(--grey-500);
    cursor: pointer;
    padding: 6px;
    transition: var(--transition);
}

.remove-file:hover {
    color: var(--error-red);
}

.remove-file svg {
    width: 20px;
    height: 20px;
}

/* Check Button */
.check-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    color: var(--white);
    border: none;
    padding: 16px 28px;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 24px;
    box-shadow: var(--shadow-md);
}

.check-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-orange-light) 0%, var(--primary-orange) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.check-btn:disabled {
    background: var(--beige-400);
    cursor: not-allowed;
    box-shadow: none;
}

.check-btn svg {
    width: 22px;
    height: 22px;
}

/* ============================================
   Results Section
   ============================================ */
.results-section {
    padding: 28px;
    border-top: 1px solid var(--beige-200);
    background: var(--white);
}

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

.results-header h3 {
    font-size: 1.2rem;
    color: var(--primary-orange);
}

.download-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--grey-800);
    color: var(--white);
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.download-btn:hover {
    background: var(--grey-900);
    transform: translateY(-1px);
}

.download-btn svg {
    width: 20px;
    height: 20px;
}

.results-content {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.document-result {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--beige-300);
}

.document-result.has-errors {
    border-left: 5px solid var(--error-red);
}

.document-result.no-errors {
    border-left: 5px solid var(--success-green);
}

.document-header {
    padding: 16px 20px;
    background: var(--beige-100);
    border-bottom: 1px solid var(--beige-200);
}

.document-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--grey-800);
    margin-bottom: 4px;
}

.document-file {
    font-size: 0.85rem;
    color: var(--grey-500);
}

.errors-list {
    padding: 0;
}

.error-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--beige-200);
    background: var(--error-light);
}

.error-item:last-child {
    border-bottom: none;
}

.error-field {
    font-weight: 700;
    color: var(--error-red);
    margin-bottom: 10px;
    font-size: 1rem;
}

.error-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.error-found,
.error-expected {
    font-size: 0.95rem;
}

.error-found .label,
.error-expected .label {
    font-weight: 600;
    color: var(--grey-600);
    display: block;
    margin-bottom: 4px;
}

.error-found .value {
    color: var(--error-red);
    font-weight: 600;
    word-break: break-word;
    background: rgba(192, 57, 43, 0.1);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.error-expected .value {
    color: var(--success-green);
    font-weight: 600;
    word-break: break-word;
    background: rgba(39, 174, 96, 0.1);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.no-errors-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    color: var(--success-green);
    font-weight: 600;
    background: var(--success-light);
}

.no-errors-message svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253, 248, 243, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 5px solid var(--beige-300);
    border-top-color: var(--primary-orange);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-spinner p {
    color: var(--grey-700);
    font-weight: 600;
    font-size: 1.05rem;
}

/* ============================================
   Chatbot Section
   ============================================ */
.chatbot-section {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 440px;
    height: 620px;
    max-height: calc(100vh - 100px);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 50px rgba(74, 63, 53, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    border: 2px solid var(--beige-300);
}

.chatbot-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    color: var(--white);
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar svg {
    width: 24px;
    height: 24px;
}

.chatbot-title h3 {
    font-size: 1.05rem;
    margin-bottom: 2px;
    color: var(--white);
}

.chatbot-subtitle {
    font-size: 0.8rem;
    opacity: 0.9;
}

.close-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--white);
}

.close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

.close-chat svg {
    width: 22px;
    height: 22px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--beige-50);
}

.welcome-message {
    text-align: center;
    padding: 28px;
    color: var(--grey-600);
}

.welcome-icon {
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    background: var(--beige-200);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-icon svg {
    width: 32px;
    height: 32px;
    color: var(--primary-orange);
}

.welcome-message h4 {
    font-size: 1.15rem;
    color: var(--grey-800);
    margin-bottom: 14px;
}

.welcome-message ul {
    text-align: left;
    padding-left: 24px;
    margin-top: 14px;
}

.welcome-message li {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.chat-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.5;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.assistant-message {
    align-self: flex-start;
    background: var(--white);
    color: var(--grey-800);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--beige-300);
}

/* Typing Indicator */
.typing-indicator .message-content {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.typing-indicator .dot {
    width: 10px;
    height: 10px;
    background: var(--beige-400);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Chat Input */
.chat-input-area {
    padding: 18px;
    border-top: 1px solid var(--beige-200);
    background: var(--white);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--beige-300);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 100px;
    transition: var(--transition);
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--primary-orange);
}

.send-btn {
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--primary-orange-dark) 100%);
    color: var(--white);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    background: linear-gradient(135deg, var(--primary-orange-light) 0%, var(--primary-orange) 100%);
    transform: scale(1.05);
}

.send-btn svg {
    width: 22px;
    height: 22px;
}

.chat-options {
    margin-top: 12px;
}

.web-search-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--grey-600);
}

.web-search-toggle input {
    display: none;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label svg {
    width: 18px;
    height: 18px;
}

.web-search-toggle input:checked + .toggle-label {
    color: var(--primary-orange);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 16px 28px;
    border-radius: var(--radius-md);
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--success-green);
    color: var(--white);
}

.toast-error {
    background: var(--error-red);
    color: var(--white);
}

.toast-info {
    background: var(--primary-orange);
    color: var(--white);
}

/* ============================================
   Saved Vessels Dropdown
   ============================================ */
.saved-vessels-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--beige-300);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.saved-vessel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
}

.saved-vessel-item:hover {
    background: var(--beige-100);
}

.saved-vessel-item .vessel-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--grey-800);
}

.saved-vessel-item .delete-vessel {
    background: transparent;
    border: none;
    color: var(--beige-400);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.saved-vessel-item .delete-vessel:hover {
    color: var(--error-red);
}

.saved-vessel-item .delete-vessel svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--grey-800);
    color: var(--beige-300);
    padding: 18px 24px;
    text-align: center;
    border-top: 4px solid var(--primary-orange);
}

.footer-content p {
    font-size: 0.95rem;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 768px) {
    .main-content {
        padding: 16px;
        gap: 16px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group.full-width {
        grid-column: 1;
    }
    
    .chatbot-section {
        width: calc(100% - 32px);
        right: 16px;
        bottom: 16px;
        height: 70vh;
    }
    
    .error-comparison {
        grid-template-columns: 1fr;
    }
    
    .custom-field-row {
        grid-template-columns: 1fr;
    }
    
    .custom-field-row input {
        width: 100%;
    }
    
    .remove-custom-field {
        justify-self: end;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 16px;
    }
    
    .logo-text {
        font-size: 1.2rem;
    }
    
    .chatbot-toggle span {
        display: none;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }
    
    .results-header {
        flex-direction: column;
        gap: 14px;
    }
    
    .download-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   Verification Panel Position (for loading overlay)
   ============================================ */
.verification-panel {
    position: relative;
}
