@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700&display=swap');

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

body {
    font-family: 'Rubik', sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.5;
}

/* ============ LOGIN PAGE ============ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header i {
    font-size: 2.5rem;
    color: #e94560;
    margin-bottom: 12px;
    display: block;
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1a1a2e;
}

.login-header p {
    color: #718096;
    font-size: 0.9rem;
    margin-top: 4px;
}

.login-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 10px;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: #718096;
}

.tab.active {
    border-color: #e94560;
    color: #e94560;
    background: #fff5f7;
}

.tab:hover:not(.active) { border-color: #cbd5e0; }

.tab-content { display: none; text-align: center; }
.tab-content.active { display: block; }

.tab-content label {
    display: block;
    text-align: left;
    font-weight: 500;
    font-size: 0.85rem;
    color: #4a5568;
    margin-bottom: 8px;
}

.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.input-group input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus { border-color: #e94560; }

.input-group button, #verify-otp-btn {
    padding: 10px 20px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.input-group button:hover, #verify-otp-btn:hover { background: #c73a52; }
.input-group button:disabled { opacity: 0.6; cursor: not-allowed; }

#verify-otp-btn { width: 100%; margin-top: 16px; padding: 12px; }

.otp-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
    direction: ltr;
}

.otp-digit {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.otp-digit:focus { border-color: #e94560; box-shadow: 0 0 0 3px rgba(233,69,96,0.15); }

.help-text { font-size: 0.8rem; color: #a0aec0; margin-top: 8px; }
.error-msg { color: #e94560; font-size: 0.85rem; margin-top: 12px; font-weight: 500; }
.loading { color: #e94560; font-size: 0.9rem; margin-top: 12px; }
.hidden { display: none !important; }

.g_id_signin { display: flex; justify-content: center; margin-top: 8px; }

/* ============ APP LAYOUT ============ */
.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 56px 1fr;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    grid-column: 1 / -1;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 10;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #4a5568;
    padding: 4px;
}

.breadcrumb {
    font-size: 0.9rem;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb i { color: #e94560; }

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a5568;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #718096;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon:hover { background: #f0f2f5; color: #e94560; }

/* Sidebar */
.sidebar {
    background: #1a1a2e;
    color: #fff;
    overflow-y: auto;
    padding: 0;
}

.sidebar-header {
    padding: 16px;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a0aec0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header i { margin-right: 8px; }

.db-tree { padding: 8px 0; }

.db-item {
    cursor: pointer;
    user-select: none;
}

.db-name {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #cbd5e0;
    transition: all 0.15s;
    gap: 8px;
}

.db-name:hover { background: rgba(255,255,255,0.06); color: #fff; }

.db-name.active { background: rgba(233,69,96,0.15); color: #e94560; }

.db-name i.fa-chevron-right { font-size: 0.6rem; transition: transform 0.2s; margin-left: auto; }
.db-name.expanded i.fa-chevron-right { transform: rotate(90deg); }

.table-list {
    display: none;
    padding: 0;
}

.table-list.visible { display: block; }

.table-item {
    display: block;
    padding: 6px 16px 6px 40px;
    font-size: 0.8rem;
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.table-item:hover { color: #fff; background: rgba(255,255,255,0.04); }
.table-item.active { color: #e94560; background: rgba(233,69,96,0.1); }

/* Main Content */
.main-content {
    overflow: auto;
    padding: 20px;
    background: #f0f2f5;
}

.welcome-screen {
    text-align: center;
    padding: 80px 20px;
    color: #a0aec0;
}

.welcome-screen i { font-size: 3rem; margin-bottom: 16px; display: block; }
.welcome-screen h2 { font-size: 1.4rem; color: #4a5568; margin-bottom: 8px; }
.welcome-screen p { font-size: 0.9rem; }

/* Table Toolbar */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right { margin-left: auto; }

.search-input {
    padding: 8px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    width: 220px;
    transition: border-color 0.2s;
}

.search-input:focus { border-color: #e94560; }

.row-count { font-size: 0.8rem; color: #a0aec0; }

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary { background: #e94560; color: #fff; }
.btn-primary:hover { background: #c73a52; }

.btn-outline {
    background: #fff;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-outline:hover { border-color: #cbd5e0; background: #f7fafc; }

.btn-danger { background: #fc5c65; color: #fff; }
.btn-danger:hover { background: #eb3b5a; }

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

/* Data Table */
.table-wrapper {
    background: #fff;
    border-radius: 12px;
    overflow: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    max-height: calc(100vh - 220px);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    background: #f7fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    z-index: 1;
}

.data-table th:hover { background: #edf2f7; }
.data-table th .sort-icon { margin-left: 4px; font-size: 0.65rem; color: #a0aec0; }
.data-table th.sorted .sort-icon { color: #e94560; }

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tr:hover td { background: #fafbfc; }

.data-table td.editable { cursor: pointer; }
.data-table td.editable:hover { background: #fffbeb; }

.data-table td.editing {
    padding: 2px;
}

.data-table td.editing input,
.data-table td.editing textarea {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid #e94560;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.82rem;
    outline: none;
}

.cell-null { color: #cbd5e0; font-style: italic; }
.cell-truncated { cursor: help; }

.actions-cell {
    white-space: nowrap;
    width: 80px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination button:hover { border-color: #e94560; color: #e94560; }
.pagination button.active { background: #e94560; color: #fff; border-color: #e94560; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Users View */
.users-view h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #1a1a2e;
}

.users-view h2 i { color: #e94560; margin-right: 8px; }

.add-user-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.input {
    padding: 8px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.input:focus { border-color: #e94560; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-body { padding: 20px; }

.modal-body .field-row {
    margin-bottom: 12px;
}

.modal-body .field-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 4px;
}

.modal-body .field-row input,
.modal-body .field-row textarea {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.modal-body .field-row input:focus,
.modal-body .field-row textarea:focus { border-color: #e94560; }

.modal-body .field-row .field-type {
    font-size: 0.7rem;
    color: #a0aec0;
    margin-top: 2px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
}

/* Structure View */
.structure-table { margin-top: 8px; }
.structure-table td { font-size: 0.8rem; }
.structure-table .pk-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.structure-table .nullable-badge {
    background: #e2e8f0;
    color: #4a5568;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
}

/* Audit View */
.audit-view h2 {
    font-size: 1.2rem;
    color: #1a1a2e;
}

.audit-view h2 i { color: #e94560; margin-right: 8px; }

.audit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.audit-tabs { display: flex; gap: 6px; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-google { background: #e8f0fe; color: #1a73e8; }
.badge-otp { background: #fef3c7; color: #92400e; }
.badge-insert { background: #d1fae5; color: #065f46; }
.badge-update { background: #dbeafe; color: #1e40af; }
.badge-delete { background: #fee2e2; color: #991b1b; }

.json-view {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.78rem;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
    max-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Change diff in audit table */
.changes-cell {
    max-width: 400px;
    white-space: normal;
    font-size: 0.78rem;
    line-height: 1.7;
}

.change-field {
    font-weight: 600;
    color: #4a5568;
}

.change-old {
    background: #fee2e2;
    color: #991b1b;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    text-decoration: line-through;
}

.change-new {
    background: #d1fae5;
    color: #065f46;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

.change-arrow {
    color: #e94560;
    font-weight: 700;
    margin: 0 2px;
}

.change-more {
    color: #a0aec0;
    font-style: italic;
    font-size: 0.72rem;
}

/* Responsive */
@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 56px;
        bottom: 0;
        width: 260px;
        z-index: 20;
        transition: left 0.3s;
    }

    .sidebar.open { left: 0; }
    .sidebar-toggle { display: block; }

    .search-input { width: 140px; }

    .add-user-form { flex-direction: column; }
    .add-user-form .input { width: 100%; }
}
