/* ===== CSS Variables ===== */
:root {
    --primary-color: #1A2B5C;
    --primary-light: #2A3F7C;
    --accent-color: #6C5CE7;
    --success-color: #10B981;
    --error-color: #EF4444;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #F1F5F9;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background: var(--bg-secondary); color: var(--text-primary); min-height: 100vh; }

/* Header */
.header { background: var(--bg-primary); border-bottom: 1px solid var(--border-color); padding: 24px 0; position: sticky; top: 0; z-index: 100; }
.header-content { max-width: 1400px; margin: 0 auto; padding: 0 32px; }
.header-text h1 { font-size: 28px; font-weight: 700; color: var(--primary-color); margin-bottom: 4px; }
.header-text p { font-size: 14px; color: var(--text-secondary); }

/* Navigation */
.nav-tabs { background: var(--bg-primary); border-bottom: 1px solid var(--border-color); position: sticky; top: 89px; z-index: 99; }
.nav-container { max-width: 1400px; margin: 0 auto; padding: 0 32px; display: flex; gap: 8px; }
.nav-tab { display: flex; align-items: center; gap: 8px; padding: 14px 20px; background: transparent; border: none; border-bottom: 2px solid transparent; font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all 0.25s ease; }
.nav-tab:hover { color: var(--primary-color); background: var(--bg-tertiary); }
.nav-tab.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.nav-tab .material-icons-outlined { font-size: 20px; }

/* Main Content */
.main-content { max-width: 1400px; margin: 0 auto; padding: 32px; }
.tab-content { display: none; animation: fadeIn 0.25s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Section Header */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.section-header h2 { font-size: 22px; font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s ease; }
.btn .material-icons-outlined { font-size: 18px; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-color); }
.btn-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 0.15s ease; }
.btn-icon:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Grids */
.documents-grid, .brands-grid, .owners-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }

/* Cards */
.card { background: var(--bg-primary); border-radius: var(--radius-lg); border: 1px solid var(--border-color); overflow: hidden; transition: all 0.25s ease; cursor: pointer; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-color); }
.card-header { padding: 20px; border-bottom: 1px solid var(--border-light); display: flex; align-items: flex-start; gap: 16px; }
.card-thumbnail { width: 64px; height: 64px; border-radius: var(--radius-md); background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.card-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.card-thumbnail .material-icons-outlined { font-size: 32px; color: var(--text-muted); }
.card-info { flex: 1; min-width: 0; }
.card-info h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-info p { font-size: 13px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { padding: 12px 20px; display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--text-muted); }
.card-meta-item { display: flex; align-items: center; gap: 4px; }
.card-meta-item .material-icons-outlined { font-size: 14px; }
.card-actions { padding: 12px 20px; border-top: 1px solid var(--border-light); display: flex; gap: 8px; }
.card-actions .btn { flex: 1; justify-content: center; }

/* Brand Card */
.brand-card .card-thumbnail { width: 80px; height: 80px; border-radius: 50%; }
.brand-card .card-thumbnail img { border-radius: 50%; }

/* Owner Card */
.owner-card .card-thumbnail { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-color), var(--accent-color)); }
.owner-card .card-thumbnail .material-icons-outlined { color: white; font-size: 24px; }

/* Loading */
.loading-state { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--text-muted); }
.loading-state .material-icons-outlined { font-size: 48px; margin-bottom: 16px; animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Modal */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; padding: 20px; overflow-y: auto; }
.modal.active { display: flex; align-items: flex-start; justify-content: center; animation: modalFadeIn 0.25s ease; }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); }
.modal-content { background: var(--bg-primary); border-radius: var(--radius-xl); width: 100%; max-width: 520px; margin: auto; position: relative; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); animation: modalSlideUp 0.25s ease; }
.modal-large { max-width: 800px; }
@keyframes modalSlideUp { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 24px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: none; border-radius: var(--radius-md); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 0.15s ease; }
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }

/* Forms */
form { padding: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.form-group .required { color: var(--error-color); }
.form-group input[type="text"], .form-group input[type="date"], .form-group select, .form-group textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 14px; font-family: inherit; background: var(--bg-primary); transition: all 0.15s ease; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(26, 43, 92, 0.1); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
select[multiple] { height: 100px; }

/* File Upload */
.file-upload { position: relative; border: 2px dashed var(--border-color); border-radius: var(--radius-md); padding: 32px; text-align: center; cursor: pointer; transition: all 0.15s ease; }
.file-upload:hover { border-color: var(--primary-color); background: var(--bg-tertiary); }
.file-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-upload-content { pointer-events: none; }
.file-upload-content .material-icons-outlined { font-size: 40px; color: var(--text-muted); margin-bottom: 12px; }
.file-upload-content p { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.file-hint { font-size: 12px; color: var(--text-muted); }
.file-preview { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-tertiary); border-radius: var(--radius-md); margin-top: 12px; }
.file-preview img { width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; }
.file-preview .material-icons-outlined { font-size: 32px; color: var(--primary-color); }
.file-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Rich Editor */
.rich-editor { border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
.editor-toolbar { display: flex; gap: 4px; padding: 8px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border-color); }
.editor-toolbar button { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; transition: all 0.15s ease; }
.editor-toolbar button:hover { background: var(--bg-primary); color: var(--text-primary); }
.editor-toolbar .separator { width: 1px; background: var(--border-color); margin: 0 4px; }
.editor-content { min-height: 150px; padding: 14px; font-size: 14px; line-height: 1.6; outline: none; }
.editor-content:empty:before { content: attr(placeholder); color: var(--text-muted); }

/* Modal Actions */
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 20px 24px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 12px; }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--bg-primary); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); animation: toastSlideIn 0.25s ease; min-width: 300px; }
.toast.success { border-left: 4px solid var(--success-color); }
.toast.error { border-left: 4px solid var(--error-color); }
.toast .material-icons-outlined { font-size: 20px; }
.toast.success .material-icons-outlined { color: var(--success-color); }
.toast.error .material-icons-outlined { color: var(--error-color); }
.toast-message { flex: 1; font-size: 14px; }
@keyframes toastSlideIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* Empty State */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; }
.empty-state .material-icons-outlined { font-size: 64px; color: var(--text-muted); margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }

/* Responsive */
@media (max-width: 1024px) {
    .brand-details, .owner-details { grid-template-columns: 1fr; }
    .brand-logo-section, .owner-logo-section { display: flex; flex-direction: column; align-items: center; }
}
@media (max-width: 768px) {
    .header-content, .nav-container, .main-content { padding-left: 16px; padding-right: 16px; }
    .nav-container { overflow-x: auto; }
    .documents-grid, .brands-grid, .owners-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .modal-content { margin: 10px; }
}

/* Link Items */
.link-item { display: flex; gap: 8px; margin-bottom: 8px; }
.link-item input { flex: 1; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 13px; }
.link-item input:focus { outline: none; border-color: var(--primary-color); }
.link-item .btn-icon { flex-shrink: 0; }

/* Link Tags */
.link-tag { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; background: var(--bg-tertiary); border-radius: var(--radius-xl); font-size: 13px; color: var(--primary-color); text-decoration: none; transition: all 0.15s ease; }
.link-tag:hover { background: var(--primary-color); color: white; }
.link-tag .material-icons-outlined { font-size: 14px; }

/* Card header clickable */
.card-header { cursor: pointer; }
.card-header:hover { background: var(--bg-tertiary); }
/* Form Tabs */
.form-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; }
.form-tab { padding: 10px 16px; background: transparent; border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all 0.15s ease; }
.form-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.form-tab.active { background: var(--primary-color); color: white; }
.form-tab-content { display: none; }
.form-tab-content.active { display: block; animation: fadeIn 0.2s ease; }

/* Files Section */
.files-section { margin-top: 16px; }
.files-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }
.files-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-top: 16px; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px; margin-top: 16px; }

/* File Card */
.file-card { background: var(--bg-tertiary); border-radius: var(--radius-md); padding: 12px; position: relative; transition: all 0.15s ease; }
.file-card:hover { background: var(--border-color); }
.file-card-thumbnail { width: 100%; aspect-ratio: 1; background: white; border-radius: var(--radius-sm); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.file-card-thumbnail img { width: 100%; height: 100%; object-fit: contain; }
.file-card-thumbnail .material-icons-outlined { font-size: 32px; color: var(--text-muted); }
.file-card-thumbnail.pdf { background: #FEE2E2; }
.file-card-thumbnail.doc { background: #D1FAE5; }
.file-card-thumbnail.image { background: #DBEAFE; }
.file-card-name { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
.file-card-actions { display: flex; gap: 4px; }
.file-card-actions .btn { flex: 1; justify-content: center; padding: 6px; font-size: 11px; }
.file-card-remove { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity 0.15s; }
.file-card:hover .file-card-remove { opacity: 1; }

/* Document Preview Modal */
.preview-modal { max-width: 900px; }
.preview-content { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
.preview-document { background: var(--bg-tertiary); border-radius: var(--radius-md); min-height: 400px; display: flex; align-items: center; justify-content: center; }
.preview-document img { max-width: 100%; max-height: 600px; }
.preview-document .material-icons-outlined { font-size: 80px; color: var(--text-muted); }
.preview-info { display: flex; flex-direction: column; gap: 16px; }
.preview-info h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.preview-info p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.preview-meta { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text-muted); }
.preview-meta-item { display: flex; align-items: center; gap: 8px; }
.preview-meta-item .material-icons-outlined { font-size: 16px; }

/* Modal Large */
.modal-large { max-width: 800px; }

/* Card Files Preview */
.card-files-preview { display: flex; gap: 6px; padding: 8px 16px; flex-wrap: wrap; }
.file-preview-item { width: 36px; height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.15s ease; }
.file-preview-item:hover { transform: scale(1.1); }
.file-preview-item.pdf { background: #FEE2E2; }
.file-preview-item.pdf .material-icons-outlined { font-size: 20px; color: #DC2626; }
.file-preview-item.image { background: #DBEAFE; overflow: hidden; }
.file-preview-item.image img { width: 100%; height: 100%; object-fit: cover; }
.file-preview-item.doc { background: #D1FAE5; }
.file-preview-item.doc .material-icons-outlined { font-size: 20px; color: #059669; }
.file-preview-more { width: 36px; height: 36px; border-radius: 6px; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--text-secondary); }

/* File Preview Modal */
.preview-modal { width: 90%; max-width: 1000px; height: 90vh; }
.preview-modal .modal-body { padding: 20px; height: calc(100% - 60px); overflow: hidden; display: flex; flex-direction: column; }
.preview-container { flex: 1; width: 100%; background: var(--bg-tertiary); border-radius: var(--radius-md); overflow: hidden; }
.preview-pdf-container { width: 100%; height: 100%; }
.preview-pdf-frame { width: 100%; height: 100%; border: none; }
.preview-image-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); }
.preview-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-color); }
