/* Skyfall Protocol - Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a0a;
    color: #fafafa;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow selection where it makes sense */
input, textarea, .selectable, .message-content, .journal-entry-body, .file-name {
    -webkit-user-select: text;
    user-select: text;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
}

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: 220px;
    min-width: 220px;
    max-width: 220px;
    height: 100%;
    background: #141414;
    color: #fafafa;
    border-right: 1px solid #262626;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 12px 16px;
    border-bottom: 1px solid #262626;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-logo-img {
    display: block;
    width: 100%;
    max-width: 180px;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}

.sidebar-nav {
    padding: 16px 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 4px;
    background: transparent;
    color: #fafafa;
    border: none;
    border-radius: 6px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-family: inherit;
}

.nav-item:hover {
    background: #262626;
}

.nav-item:active {
    transform: scale(0.98);
}

.nav-item.active {
    background: #f97316;
    color: #0a0a0a;
    font-weight: 600;
}

/* Sidebar footer with storage indicator */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #262626;
    flex-shrink: 0;
}

.storage-indicator {
    font-size: 11px;
    color: #a3a3a3;
}

.storage-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: #6b7280;
}

.storage-bar-container {
    width: 100%;
    height: 4px;
    background: #262626;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.storage-bar-fill {
    height: 100%;
    background: #f97316;
    width: 0%;
    transition: width 0.3s;
}

.storage-bar-fill.warning {
    background: #f59e0b;
}

.storage-bar-fill.critical {
    background: #ef4444;
}

.storage-text {
    font-size: 11px;
    color: #a3a3a3;
}

/* Main content */
.main-content {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: #0a0a0a;
    overflow: hidden;
    position: relative;
}

/* View containers */
.view-container {
    display: none;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    background: #0a0a0a;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.view-container.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

/* Page header pattern (used by most views) */
.page-header {
    padding: 20px;
    background: #141414;
    border-bottom: 1px solid #262626;
    flex-shrink: 0;
}

.page-header h2 {
    margin: 0;
    font-size: 24px;
    color: #f97316;
}

.page-header p {
    margin: 8px 0 0 0;
    color: #a3a3a3;
    font-size: 14px;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}

/* Toast notification system */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    background: #262626;
    color: #fafafa;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-left: 4px solid #f97316;
    max-width: 350px;
    word-wrap: break-word;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease-in-out;
    pointer-events: auto;
    cursor: pointer;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success { border-left-color: #10b981; }
.toast.warning { border-left-color: #f59e0b; }
.toast.error { border-left-color: #ef4444; }

.toast .toast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.toast .toast-message {
    font-size: 13px;
    opacity: 0.9;
}

/* Common button styles */
.btn-primary {
    background: #f97316;
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary {
    background: #1a1a1a;
    border: 1px solid #262626;
    color: #a3a3a3;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-secondary:hover {
    background: #262626;
    color: #e5e5e5;
}

/* Common form styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #a3a3a3;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #262626;
    border-radius: 6px;
    padding: 10px 12px;
    color: #e5e5e5;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #f97316;
    background: #1f1f1f;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Modal base */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: #141414;
    border: 1px solid #262626;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #262626;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    color: #f97316;
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: #a3a3a3;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #e5e5e5;
    background: #262626;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #262626;
    flex-shrink: 0;
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
    flex: 1;
}

/* Empty state pattern */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #a3a3a3;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    color: #e5e5e5;
    font-size: 18px;
    margin-bottom: 8px;
}

.empty-state p {
    max-width: 360px;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0f0f0f;
}

::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #525252;
}

/* Mobile responsive: sidebar collapses to bottom nav */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: auto;
        max-height: 60px;
        border-right: none;
        border-bottom: 1px solid #262626;
        order: 2;
        flex-direction: row;
    }

    .sidebar-header,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
        gap: 4px;
        flex: 1;
        white-space: nowrap;
    }

    .nav-item {
        flex-shrink: 0;
        width: auto;
        padding: 8px 12px;
        font-size: 13px;
        margin-bottom: 0;
    }

    .main-content {
        order: 1;
        flex: 1;
    }

    .page-header {
        padding: 16px;
    }

    .page-header h2 {
        font-size: 20px;
    }
}
