/* Layout & Base */
:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --header-bg: #000000;
    --bg: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-secondary: #6B7280;
    --text-on-header: #FFFFFF;
    --border: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sidebar-width: 220px; /* Reduced width */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* App Layout */
#app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: #000000;
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-header {
    padding: 1.25rem 1rem; /* Smaller padding */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
}

.sidebar-logo {
    height: 40px; /* Smaller logo */
    width: auto;
    image-rendering: -webkit-optimize-contrast;
}

.sidebar-nav {
    padding: 1rem 0.75rem; /* Smaller padding */
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* Tighter gap */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem; /* Smaller padding */
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem; /* Smaller text */
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

.nav-icon {
    font-size: 1rem; /* Smaller icon */
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
}

.footer-text {
    margin: 0;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents overflow */
    position: relative;
}

.top-header {
    height: 64px;
    background-color: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: flex-end; /* Auth on right */
    align-items: center;
    padding: 0 2rem;
    position: relative;
    z-index: 100;
}

.content-container {
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
}

/* View Sections */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Auth Section (Top Right) */
#auth-container {
    display: flex;
    align-items: center;
    height: 100%;
    position: relative;
}

.profile-menu {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    z-index: 110;
}

.profile-menu:hover {
    background-color: #F3F4F6;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
    font-weight: 500;
    pointer-events: none; /* Let parent handle hover */
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Dropdown Content */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    padding-top: 8px; /* Bridge gap */
    z-index: 200;
}

.dropdown-inner {
    background-color: white;
    min-width: 200px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Show dropdown on menu hover */
.profile-menu:hover .dropdown-content {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    color: var(--text-main);
    font-size: 0.875rem;
    transition: background-color 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: #F3F4F6;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 0;
}

/* Memory Items */
.memory-item {
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.memory-text {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background-color: #FEE2E2;
    color: #DC2626;
}

/* Custom Inline Confirmation */
.delete-confirm-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.confirm-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #DC2626;
    text-transform: uppercase;
}

.btn-confirm {
    background-color: #DC2626;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
}

.btn-confirm:hover {
    background-color: #B91C1C;
}

.btn-cancel {
    background-color: #F3F4F6;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-cancel:hover {
    background-color: #E5E7EB;
}

/* LOGIN STATE STYLES */
body.login-mode {
    background-color: #000000;
    justify-content: center;
    background-image: none;
}

body.login-mode #app-layout {
    display: none !important;
}

/* Dark Login Card (Modified per request) */
#login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    margin: auto;
    width: 100%;
}

#login-prompt h2, #login-prompt p {
    display: none;
}

.login-circle {
    width: 320px;
    height: 320px;
    background-color: #000000;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 0 60px rgba(249, 115, 22, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.login-logo {
    display: block;
    height: 90px;
    width: auto;
    image-rendering: -webkit-optimize-contrast;
    margin-top: -10px;
}

#g_id_signin_button {
    display: flex;
    justify-content: center;
    z-index: 10;
}

/* Dashboard Card */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 2rem;
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Reminders */
.reminder-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
}

.reminder-task {
    font-weight: 500;
    display: block;
    margin-bottom: 0.25rem;
}

.reminder-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: #FFF7ED;
    color: #C2410C;
    border: 1px solid #FFEDD5;
}

/* Users Table */
.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.users-table th,
.users-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    font-weight: 600;
    color: var(--text-on-header);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: var(--header-bg);
}

.users-table tbody tr:hover {
    background-color: #F9FAFB;
}

.users-table .role-select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    background-color: white;
    min-width: 140px;
}

.users-table .role-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

/* Secondary Button */
.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s;
}

.btn-secondary:hover {
    background-color: #FFF7ED;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon {
    font-size: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Status Messages */
.success-message {
    background-color: #ECFDF5;
    color: #047857;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid #D1FAE5;
}

.error-message {
    background-color: #FEF2F2;
    color: #B91C1C;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border: 1px solid #FECACA;
}

.loading-message {
    color: var(--text-secondary);
    padding: 2rem;
    text-align: center;
}

/* Role Badge Colors - On Brand */
.role-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
}

.role-admin { 
    background-color: var(--primary); 
    color: white; 
    border: 1px solid var(--primary);
}

.role-team { 
    background-color: #374151;
    color: white;
    border: 1px solid #374151;
}

.role-user { 
    background-color: #F3F4F6;
    color: var(--text-secondary);
    border: 1px solid #E5E7EB;
}

/* Admin Form Styling */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

#cloze-submit-btn {
    min-width: 200px;
}

/* Loading Spinner */
.spinner-inline {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.input-with-spinner {
    display: flex;
    align-items: center;
    position: relative;
}

.input-with-spinner input {
    flex: 1;
}

.input-with-spinner .spinner-inline {
    position: absolute;
    right: 12px;
}
