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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #1a1a2e;
    color: #fff;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #16213e;
    border-bottom: 1px solid #333;
}

.logo h1 {
    font-size: 1.5rem;
    color: #4a90d9;
}

.nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #333;
    color: #888;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    border-color: #4a90d9;
    color: #fff;
}

.nav-btn.active {
    background: #4a90d9;
    border-color: #4a90d9;
    color: #fff;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.btn:hover {
    background: #444;
}

.btn-primary {
    background: #4a90d9;
}

.btn-primary:hover {
    background: #357abd;
}

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

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

/* Inputs */
.input {
    padding: 8px 12px;
    background: #0f0f23;
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
}

.input:focus {
    outline: none;
    border-color: #4a90d9;
}

.input-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.select {
    padding: 8px 12px;
    background: #0f0f23;
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    overflow: hidden;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Files Tab - Split Layout */
#files-tab {
    display: none;
    gap: 20px;
    height: calc(100vh - 120px);
}

#files-tab.active {
    display: flex;
}

.folders-sidebar {
    width: 300px;
    background: #16213e;
    border-radius: 8px;
    padding: 15px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

.folders-sidebar h3 {
    margin-bottom: 15px;
    color: #4a90d9;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.folders-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
}

.folder-item {
    padding: 12px 15px;
    background: #0f0f23;
    border: 1px solid #333;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.folder-item:hover {
    border-color: #4a90d9;
    background: #1a2d4d;
}

.folder-item.active {
    border-color: #4a90d9;
    background: #1e3a5f;
    box-shadow: 0 0 10px rgba(74, 144, 217, 0.3);
}

.folder-item .folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.folder-item .folder-delete {
    color: #f44336;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.5;
    font-size: 16px;
}

.folder-item .folder-delete:hover {
    opacity: 1;
}

.folder-item .folder-count {
    color: #666;
    font-size: 12px;
    margin-left: 10px;
}

.add-folder {
    margin-top: auto;
    display: flex;
    gap: 8px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.add-folder .input {
    flex: 1;
    min-width: 0;
}

.files-main {
    flex: 1;
    background: #16213e;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.files-container {
    flex: 1;
    overflow-y: auto;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.current-folder {
    font-size: 18px;
    color: #4a90d9;
    font-weight: 500;
}

.breadcrumb-back {
    color: #888;
    cursor: pointer;
    font-size: 14px;
}

.breadcrumb-back:hover {
    color: #fff;
}

.folder-link {
    color: #4a90d9;
    cursor: pointer;
}

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

.toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Files Table */
.files-table {
    width: 100%;
    border-collapse: collapse;
}

.files-table th,
.files-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.files-table th {
    color: #888;
    font-weight: 500;
    font-size: 13px;
    position: sticky;
    top: 0;
    background: #16213e;
    z-index: 1;
}

.files-table tr:hover td {
    background: #1a2d4d;
}

.files-table .loading,
.files-table .empty {
    text-align: center;
    color: #666;
    padding: 60px 40px;
    font-size: 16px;
}

/* File row styling */
.file-row {
    transition: background 0.2s;
}

.file-row:hover {
    background: #1a2d4d;
}

.file-icon {
    font-size: 18px;
    margin-right: 8px;
}

/* Pagination */
.pagination {
    margin-top: 15px;
    text-align: center;
}

/* Presets */
.presets-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.preset-card {
    background: #16213e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
}

.preset-card h4 {
    margin-bottom: 10px;
    color: #4a90d9;
}

.preset-card p {
    color: #888;
    font-size: 13px;
    margin-bottom: 10px;
}

.preset-card code {
    background: #0f0f23;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

/* Account Info */
.account-info {
    background: #16213e;
    border-radius: 8px;
    padding: 20px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #333;
}

.info-row:last-child {
    border: none;
}

.info-label {
    color: #888;
}

.info-value {
    color: #4caf50;
}

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

.modal-content {
    background: #16213e;
    border-radius: 12px;
    padding: 25px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #4a90d9;
}

.form-group {
    margin-bottom: 15px;
}

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

.form-group .input {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Links Modal */
.link-row {
    margin-bottom: 15px;
}

.link-row label {
    display: block;
    margin-bottom: 5px;
    color: #888;
    font-size: 13px;
}

.link-row .input {
    width: calc(100% - 50px);
    margin-right: 10px;
}

/* Utilities */
.loading {
    color: #666;
}

.success-message {
    background: #1e4620;
    color: #4caf50;
    padding: 12px;
    border-radius: 6px;
}

.error-message {
    background: #4a1515;
    color: #f44336;
    padding: 12px;
    border-radius: 6px;
}

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

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

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

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

/* Domain Badges */
.domain-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 8px;
}

.domain-badge.k2s {
    background: #4a90d9;
    color: #fff;
}

.domain-badge.tezfiles {
    background: #9c27b0;
    color: #fff;
}

.domain-badge.fboom {
    background: #ff5722;
    color: #fff;
}

/* Folder Groups */
.folder-group {
    margin-bottom: 15px;
}

.folder-group-title {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

/* Add folder form */
.add-folder {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.add-folder .input {
    flex: 1;
    min-width: 100px;
}

.add-folder .select-sm {
    padding: 6px 8px;
    font-size: 11px;
    min-width: 80px;
}

.folders-sidebar h4 {
    font-size: 12px;
    color: #888;
    margin: 10px 0;
}

.folders-sidebar hr {
    border: none;
    border-top: 1px solid #333;
    margin: 15px 0;
}

/* Custom Dialog Overlay */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.dialog-box {
    background: #1a1a2e;
    border: 1px solid #4a90d9;
    border-radius: 12px;
    padding: 25px;
    min-width: 320px;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.2s ease;
}

.dialog-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 15px;
}

.dialog-icon.info { color: #4a90d9; }
.dialog-icon.success { color: #4caf50; }
.dialog-icon.warning { color: #ff9800; }
.dialog-icon.error { color: #f44336; }
.dialog-icon.confirm { color: #ff9800; }

.dialog-title {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
    color: #fff;
}

.dialog-message {
    text-align: center;
    color: #aaa;
    margin-bottom: 25px;
    line-height: 1.5;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.dialog-buttons .btn {
    min-width: 100px;
}

.dialog-btn-cancel {
    background: #333;
}

.dialog-btn-cancel:hover {
    background: #444;
}

.dialog-btn-confirm {
    background: #4a90d9;
}

.dialog-btn-confirm:hover {
    background: #357abd;
}

.dialog-btn-danger {
    background: #d32f2f;
}

.dialog-btn-danger:hover {
    background: #b71c1c;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px 20px;
    min-width: 280px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-icon {
    font-size: 24px;
}

.toast.success { border-left: 4px solid #4caf50; }
.toast.success .toast-icon { color: #4caf50; }

.toast.error { border-left: 4px solid #f44336; }
.toast.error .toast-icon { color: #f44336; }

.toast.warning { border-left: 4px solid #ff9800; }
.toast.warning .toast-icon { color: #ff9800; }

.toast.info { border-left: 4px solid #4a90d9; }
.toast.info .toast-icon { color: #4a90d9; }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 3px;
}

.toast-message {
    color: #888;
    font-size: 13px;
}

.toast-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
}

.toast-close:hover {
    color: #fff;
}

/* Link modal improvements */
.link-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px;
    background: #16213e;
    border-radius: 6px;
}

.link-row label {
    min-width: 100px;
    color: #888;
}

.link-row .input {
    flex: 1;
}

.link-not-found {
    opacity: 0.6;
}

.link-missing {
    flex: 1;
    color: #ff6b6b;
    font-style: italic;
}

.link-note {
    margin-top: 15px;
    padding: 10px;
    background: #2a2a4a;
    border-radius: 6px;
    color: #ffd93d;
    font-size: 13px;
}
