:root {
    --primary-color: #4F46E5; /* Indigo 600 */
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --bg-color: #F3F4F6; /* Gray 100 */
    --surface-color: #FFFFFF;
    --text-primary: #111827; /* Gray 900 */
    --text-secondary: #6B7280; /* Gray 500 */
    --success-color: #10B981; /* Emerald 500 */
    --danger-color: #EF4444; /* Red 500 */
    --warning-color: #F59E0B; /* Amber 500 */
    --border-color: #E5E7EB;
    
    --bottom-nav-height: 65px;
    --header-height: 60px;
    --app-max-width: 480px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #E5E7EB; /* Darker gray outside the app container */
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#phone-wrapper {
    width: 100%;
    max-width: var(--app-max-width);
    height: 100vh;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

#app-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 481px) {
    #phone-wrapper {
        height: 90vh;
        border-radius: 24px;
        overflow: hidden;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

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

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px -1px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.badge-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: var(--danger-color);
    border-radius: 50%;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

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

/* Inputs */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

select.input-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.5rem;
    padding-right: 2.5rem;
}

/* Layouts */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: var(--bg-color);
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    padding-bottom: calc(var(--bottom-nav-height) + 1.5rem);
}

.header {
    height: var(--header-height);
    background-color: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-weight: 600;
    font-size: 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

/* Bottom Navigation */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border-color);
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    flex: 1;
    height: calc(100% - 8px);
    margin: 4px 2px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.12);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Cards */
.card {
    background-color: var(--surface-color);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* Modals & Popups */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--surface-color);
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: scale(0.95);
    opacity: 0;
    animation: modalIn 0.3s forwards ease-out;
}

@keyframes modalIn {
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-body {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    gap: 1rem;
}

/* Utilities */
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-secondary { color: var(--text-secondary); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }

/* Specific components */
.credit-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}
.list-item:last-child {
    border-bottom: none;
}

.checkbox-custom {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    appearance: none;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.checkbox-custom:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-custom:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.checkbox-custom:not(:disabled) {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
}

.checkbox-custom:disabled {
    opacity: 0.5;
    background-color: var(--bg-color);
    cursor: not-allowed;
    border-color: var(--border-color);
}

.checkbox-custom:disabled::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 8px;
    width: 12px;
    height: 2px;
    background-color: #999;
    transform: rotate(-45deg);
}

/* Notice/Community UI */
.notice-card {
    border-left: 4px solid var(--primary-color);
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--surface-color);
    padding: 0.25rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* --- CHATBOT WIDGET --- */
.chatbot-widget {
    position: absolute;
    bottom: 90px; /* Above the bottom navigation */
    right: 20px;
    z-index: 90;
    font-family: 'Inter', sans-serif;
}
.chatbot-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    position: relative;
    transition: transform 0.2s;
}
.chatbot-icon:hover {
    transform: scale(1.05);
}
.chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: red;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 50%;
    border: 2px solid white;
}
.chatbot-window {
    position: fixed;
    top: 60px;
    bottom: 90px;
    right: 20px;
    left: 20px;
    width: auto;
    max-width: 340px;
    height: auto;
    max-height: none;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.chatbot-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chatbot-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.chatbot-header .btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}
.chatbot-messages {
    flex: 1;
    padding: 1rem 1rem 60px 1rem;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
.chat-msg {
    max-width: 80%;
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}
.chat-msg.system {
    align-self: flex-start;
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
}
.chatbot-faq-menu {
    position: absolute;
    bottom: 55px; /* sit above the input area */
    left: 0;
    right: 0;
    background: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    padding: 0 1rem 1rem 1rem;
    max-height: 400px;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform: translateY(calc(100% - 40px)); /* Leaves drag handle visible */
    z-index: 10;
}
.chatbot-faq-menu.open {
    transform: translateY(0);
}
.faq-drag-handle-container {
    padding: 15px 0; /* large vertical hit area */
    display: flex;
    justify-content: center;
    cursor: grab;
    margin-bottom: 5px;
}
.faq-drag-handle-container:active {
    cursor: grabbing;
}
.faq-drag-handle {
    width: 50px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 3px;
}
.faq-btn {
    background: white;
    border: none;
    color: var(--text-primary);
    padding: 0.8rem;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    border-radius: 8px;
}
.faq-btn:hover {
    background: #f1f5f9;
}
.chatbot-input {
    display: flex;
    padding: 0.8rem;
    background: white;
    border-top: 1px solid #e2e8f0;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 20;
}
.chatbot-input textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 0.6rem 1rem;
    font-family: inherit;
    font-size: 0.85rem;
    resize: none;
    outline: none;
    height: 38px;
}
.chatbot-input textarea:focus {
    border-color: var(--primary-color);
}
.chatbot-input button {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}
.chatbot-footer {
    padding: 0.8rem;
    background: white;
    border-top: 1px solid #e2e8f0;
}

/* Modal Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #334155;
    font-size: 0.95rem;
}
.form-group .form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    background: #f8fafc;
}
.form-group .form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group textarea.form-control {
    resize: vertical;
    min-height: 100px;
}
.form-group select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 2.5rem;
}

/* Unified Input Styles for Modals */
.form-group .form-control.form-control-unified,
.form-group input.form-control,
.form-group textarea.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) inset;
    line-height: 1.5;
}
.form-group input.form-control:hover,
.form-group textarea.form-control:hover {
    border-color: #cbd5e1;
    background: #ffffff;
}
.form-group input.form-control:focus,
.form-group textarea.form-control:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15), 0 2px 4px rgba(0,0,0,0.02) inset;
}
.form-group textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* Custom Instant Tooltip for Substitute Classes */
.sub-tooltip {
    position: relative;
}
.sub-tooltip:hover::after {
    content: attr(data-sub-tooltip);
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.sub-tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    z-index: 9999;
    pointer-events: none;
}
