* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #ffffff;
    --bg-sidebar: #f3f4f6;
    --bg-card: #f9fafb;
    --bg-input: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --accent: #0891b2;
    --border: #e5e7eb;
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px;
}

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

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
}

.contract-list {
    flex: 1;
    overflow-y: auto;
}

.contract-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-card);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.contract-item:hover {
    background: var(--bg-input);
}

.contract-item .name {
    font-size: 13px;
    font-weight: 500;
    word-break: break-word;
}

.contract-item .chunks {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.contract-item .actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.btn {
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    transition: background 0.15s;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    font-size: 11px;
    padding: 4px 10px;
}

.btn-xs {
    font-size: 10px;
    padding: 3px 8px;
}

.btn-full {
    width: 100%;
    padding: 10px 14px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

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

.btn-danger {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

.ingest-status {
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.5;
}

.ingest-status.success { background: rgba(52, 211, 153, 0.1); color: var(--success); }
.ingest-status.error { background: rgba(248, 113, 113, 0.1); color: var(--error); }
.ingest-status.loading { background: rgba(99, 102, 241, 0.1); color: var(--primary); }

.hidden { display: none; }

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.top-bar h1 {
    font-size: 18px;
    font-weight: 600;
}

.mode-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-sidebar);
    border-radius: var(--radius);
    padding: 3px;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* Chat area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.welcome-message h3 {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 12px;
}

.message {
    max-width: 800px;
    margin: 0 auto 20px;
    padding: 16px 20px;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 14px;
}

.message.user {
    background: var(--primary);
    color: white;
    margin-left: auto;
    max-width: 600px;
    border-bottom-right-radius: 2px;
}

.message.assistant {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

.message.assistant .sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.message.assistant .source-tag {
    display: inline-block;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    margin: 2px 4px 2px 0;
    font-size: 11px;
}

.message.loading {
    color: var(--text-muted);
    font-style: italic;
}

.message pre {
    background: var(--bg);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message ul, .message ol {
    padding-left: 20px;
    margin: 8px 0;
}

.message li {
    margin-bottom: 4px;
}

.message p {
    margin-bottom: 8px;
}

.message p:last-child {
    margin-bottom: 0;
}

.message strong {
    color: var(--accent);
}

/* Input area */
.input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.filter-row label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-row select {
    flex: 1;
    max-width: 400px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 13px;
}

.input-row {
    display: flex;
    gap: 10px;
}

.input-row textarea {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
}

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

.input-row .btn {
    align-self: flex-end;
    padding: 10px 24px;
}

.empty-state {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 12px;
    color: var(--text-muted);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.upload-icon {
    font-size: 20px;
    font-weight: 300;
    color: var(--primary);
}

.upload-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
}

.upload-status {
    padding: 8px;
    border-radius: var(--radius);
    font-size: 11px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.upload-status.success { background: rgba(52, 211, 153, 0.1); color: var(--success); }
.upload-status.error { background: rgba(248, 113, 113, 0.1); color: var(--error); }
.upload-status.loading { background: rgba(99, 102, 241, 0.1); color: var(--primary); }

/* Olmazsa Olmazlar paneli */
.must-haves-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.must-haves-panel h2 {
    font-size: 18px;
    margin-bottom: 4px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 13px;
}

.mh-header {
    margin-bottom: 24px;
}

.mh-editor {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    max-width: 800px;
}

.mh-textarea {
    width: 100%;
    min-height: 400px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
}

.mh-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.mh-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.mh-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.mh-save-status {
    font-size: 13px;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════ */

.login-wrapper {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text);
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.login-form input[type="email"],
.login-form input[type="password"] {
    width: 100%;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--error);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════
   FIRMALAR PANEL
   ═══════════════════════════════════════════════════════ */

.firmalar-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

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

.firmalar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* Firma form */
.firma-form-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.firma-form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.firma-form .form-group {
    flex: 1;
    min-width: 180px;
}

.firma-form .form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.firma-form input[type="text"],
.firma-form input[type="date"] {
    width: 100%;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
}

.firma-form input[type="file"] {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 12px;
}

.firma-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.firma-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Firmalar table */
.firmalar-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.firmalar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.firmalar-table thead th {
    background: var(--bg-sidebar);
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.firmalar-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.firmalar-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

.actions-cell {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.file-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
}

.file-link:hover {
    text-decoration: underline;
}

/* Expiry date colors */
.expiry-expired {
    color: var(--error);
    font-weight: 600;
}

.expiry-warning {
    color: var(--warning);
    font-weight: 600;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
