/* ========================================
   Main CSS - Layout & App Styles
   ======================================== */

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-gray-900);
    background: white;
}

a {
    color: var(--color-primary-500);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

/* ========================================
   App Layout
   ======================================== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    min-width: 280px;
}

/* App Dashboard - Takes full vertical space */
.app-dashboard {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app__header {
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.app__header-actions {
    display: flex;
    gap: var(--space-1);
}

.app__header-actions--left {
    display: flex;
    gap: var(--space-1);
}

/* Contact Section */
.app__contact {
    flex-shrink: 0;
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-gray-200);
}

/* Tabs Section */
.app__tabs {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
}

/* Content Section */
.app__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tab Panel */
.tab-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.tab-panel--active {
    display: flex;
}

/* Tab Panel with Fixed Bottom Action */
.tab-panel--with-action {
    display: none;
    flex-direction: column;
    flex: 1;
}

.tab-panel--with-action.tab-panel--active {
    display: flex;
}

.tab-panel__content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-panel__action {
    flex-shrink: 0;
    padding: var(--space-3);
    border-top: 1px solid var(--color-gray-200);
    background: var(--bg-primary, white);
}

/* ========================================
   Page Sections
   ======================================== */

/* Detail View */
.detail-view {
    padding: 0;
}

.detail-view__header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-gray-200);
}

.detail-view__back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-gray-500);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-bottom: var(--space-2);
}

.detail-view__back:hover {
    color: var(--color-gray-700);
}

.detail-view__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.detail-view__title h2 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-gray-900);
}

.detail-view__meta {
    font-size: var(--text-sm);
    color: var(--color-gray-500);
}

.detail-view__actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.detail-view__content {
    padding: var(--space-3);
}

/* Document Item */
.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-gray-100);
}

.document-item:last-child {
    border-bottom: none;
}

.document-item__info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.document-item__icon {
    color: var(--color-gray-400);
    font-size: var(--icon-lg);
}

.document-item__content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.document-item__name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-gray-900);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.document-item__meta {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
}

/* ========================================
   Utility Classes
   ======================================== */

.hidden {
    display: none !important;
}

.text-muted {
    color: var(--color-gray-500);
}

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

.text-error {
    color: var(--color-error);
}

.text-center {
    text-align: center;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 {
    gap: var(--space-1);
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

.p-2 {
    padding: var(--space-2);
}

.p-3 {
    padding: var(--space-3);
}

.p-4 {
    padding: var(--space-4);
}

.mt-2 {
    margin-top: var(--space-2);
}

.mt-3 {
    margin-top: var(--space-3);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mb-3 {
    margin-bottom: var(--space-3);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-400);
}