/* Reset and Base - Dark Theme */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0d1117;
    color: #e6edf3;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: #161b22;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #30363d;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: #58a6ff;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #58a6ff;
}

.nav-links .logout-link {
    color: #f85149;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: #1f3d2a;
    color: #3fb950;
    border: 1px solid #238636;
}

.alert-error {
    background: #3d1f1f;
    color: #f85149;
    border: 1px solid #da3633;
}

.alert-info {
    background: #1f3d5c;
    color: #58a6ff;
    border: 1px solid #1f6feb;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    color: #e6edf3;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid #30363d;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #21262d;
    color: #c9d1d9;
}

.btn:hover {
    background: #30363d;
    border-color: #8b949e;
}

.btn-primary {
    background: #238636;
    border-color: #238636;
    color: white;
}

.btn-primary:hover {
    background: #2ea043;
    border-color: #2ea043;
}

.btn-danger {
    background: #da3633;
    border-color: #da3633;
    color: white;
}

.btn-danger:hover {
    background: #f85149;
    border-color: #f85149;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.btn-full {
    width: 100%;
}

/* Tables */
.table-container {
    background: #161b22;
    border-radius: 8px;
    border: 1px solid #30363d;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #21262d;
}

.data-table th {
    background: #0d1117;
    font-weight: 600;
    color: #8b949e;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.data-table tr:hover {
    background: #1c2128;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #1f3d2a;
    color: #3fb950;
}

.badge-danger {
    background: #3d1f1f;
    color: #f85149;
}

/* Cards */
.card {
    background: #161b22;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #30363d;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #e6edf3;
}

.card .subtitle {
    color: #8b949e;
    margin-bottom: 1rem;
}

/* Credentials Box */
.credentials-box {
    background: #0d1117;
    border-radius: 6px;
    padding: 1rem;
    border: 1px solid #30363d;
}

.credential-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #21262d;
}

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

.credential-item label {
    font-weight: 600;
    color: #8b949e;
}

.credential-item code {
    background: #21262d;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    color: #e6edf3;
}

.credential-item code.password {
    background: #0d419d;
    color: #79c0ff;
}

/* Forms */
.form-container {
    background: #161b22;
    border-radius: 8px;
    padding: 2rem;
    border: 1px solid #30363d;
    max-width: 600px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #e6edf3;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: #0d1117;
    color: #e6edf3;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #58a6ff;
}

.form-group input:disabled {
    background: #21262d;
    color: #8b949e;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #8b949e;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Checkbox Grid */
.checkbox-grid {
    display: grid;
    gap: 0.75rem;
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-item:hover {
    background: #1c2128;
    border-color: #8b949e;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin-top: 0.25rem;
    accent-color: #238636;
}

.checkbox-label {
    display: flex;
    flex-direction: column;
}

.checkbox-label strong {
    color: #e6edf3;
}

.checkbox-label small {
    color: #8b949e;
    margin-top: 0.25rem;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-box {
    background: #161b22;
    padding: 2.5rem;
    border-radius: 8px;
    border: 1px solid #30363d;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: #58a6ff;
}

.login-box .subtitle {
    text-align: center;
    color: #8b949e;
    margin-bottom: 2rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: #161b22;
    border-radius: 8px;
    border: 1px solid #30363d;
}

.empty-state p {
    color: #8b949e;
    margin-bottom: 1rem;
}

/* Info Box */
.info-box {
    background: #0d1117;
    border: 1px solid #1f6feb;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-top: 1.5rem;
}

.info-box h3 {
    color: #58a6ff;
    margin-bottom: 0.5rem;
}

.info-box p {
    color: #8b949e;
    margin: 0.25rem 0;
}

/* Instructions Box (copyable) */
.instructions-box {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.instructions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    border-radius: 8px 8px 0 0;
}

.instructions-header h3 {
    color: #e6edf3;
    font-size: 0.9rem;
    margin: 0;
}

.copy-btn {
    background: #238636;
    border: none;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: #2ea043;
}

.copy-btn.copied {
    background: #1f6feb;
}

.instructions-content {
    padding: 1rem;
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.8;
    color: #c9d1d9;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Danger Zone */
.danger-zone {
    background: #161b22;
    border: 1px solid #f85149;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.danger-zone h2 {
    color: #f85149;
    margin-bottom: 0.5rem;
}

.danger-zone p {
    color: #8b949e;
    margin-bottom: 1rem;
}

/* Folder List */
.folder-list {
    list-style: none;
}

.folder-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #21262d;
}

.folder-list li:last-child {
    border-bottom: none;
}

/* Utility Classes */
.text-muted {
    color: #8b949e;
}

a {
    color: #58a6ff;
}

a:hover {
    text-decoration: underline;
}

code {
    background: #21262d;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #e6edf3;
}

/* Footer */
.footer {
    background: #161b22;
    color: #8b949e;
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    border-top: 1px solid #30363d;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Folder Path Styles */
.folder-path {
    color: #8b949e;
    font-family: monospace;
    font-size: 0.8em;
    display: block;
    margin-top: 0.25rem;
}

.folder-path-inline {
    color: #8b949e;
    font-family: monospace;
    font-size: 0.85em;
    margin-left: 0.5rem;
}

/* Tree Browser Styles */
.breadcrumb {
    padding: 0.75rem 1rem;
    background: #0d1117;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-family: monospace;
    color: #8b949e;
    overflow-x: auto;
    white-space: nowrap;
}

.breadcrumb-item {
    color: #8b949e;
}

.breadcrumb-item.clickable {
    color: #58a6ff;
    cursor: pointer;
}

.breadcrumb-item.clickable:hover {
    text-decoration: underline;
}

.folder-tree {
    min-height: 200px;
}

.folder-tree .loading,
.folder-tree .empty,
.folder-tree .error {
    text-align: center;
    padding: 2rem;
    color: #8b949e;
}

.folder-tree .error {
    color: #f85149;
}

.folder-tree .folder-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    transition: all 0.2s;
}

.folder-item:hover {
    background: #1c2128;
    border-color: #8b949e;
}

.folder-item.in-db {
    background: #1f3d2a;
    border-color: #238636;
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.folder-icon {
    font-size: 1.25rem;
}

.folder-name {
    color: #e6edf3;
    font-weight: 500;
}

.folder-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    margin: 1rem;
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: #e6edf3;
}

.modal-content .form-group {
    margin-bottom: 1rem;
}

.modal-content .form-actions {
    margin-top: 1.5rem;
}

/* Large Modal for Folder Browser */
.modal-large {
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #30363d;
}

.modal-header h3 {
    margin: 0;
}

.modal-large .folder-tree {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

/* Selected Folders List */
.selected-folders-list {
    margin-top: 1rem;
}

.selected-folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.selected-folder-item:hover {
    background: #1c2128;
    border-color: #8b949e;
}

.selected-folder-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.selected-folder-info strong {
    color: #e6edf3;
}

.selected-folder-info .folder-path {
    color: #8b949e;
    font-family: monospace;
    font-size: 0.8em;
}

/* Folder Item Selected State in Modal */
.folder-item.selected {
    background: #1f3d2a;
    border-color: #238636;
}

.folder-item input[type="checkbox"] {
    width: auto;
    accent-color: #238636;
    cursor: pointer;
}
