:root {
    --color-primary: #9058EF;
    --color-primary-light: #A679F2;

    /* Light Theme Defaults */
    --color-background: #FFFFFF;
    --color-surface: #F9FAFB;
    --color-text-primary: #111827;
    --color-text-secondary: #6B7280;
    --color-border: #E5E7EB;

    --font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.dark-mode {
    /* Dark Theme Overrides */
    --color-background: #111827;
    --color-surface: #1F2937;
    --color-text-primary: #F9FAFB;
    --color-text-secondary: #9CA3AF;
    --color-border: #374151;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: 16px;
    background-color: var(--color-background);
    color: var(--color-text-primary);
}

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

.sidebar {
    width: 280px;
    height: 100vh;
    background-color: var(--color-surface);
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-right: 1px solid var(--color-border);
    box-sizing: border-box;
}

.sidebar-top {
    flex-grow: 1;
}

.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 40px;
}

.sidebar-logo {
    max-width: 200px;
    margin-bottom: 10px;
}

.add-inbox-btn {
    display: block;
    margin-bottom: 10px;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.main-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0;
}

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 24px 0;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background-image: linear-gradient(to right, #9058EF, #A679F2);
    color: #FFFFFF;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary:disabled,
.btn-primary[disabled] {
    cursor: not-allowed;
    background-image: none;
    background-color: #D1D5DB; /* Light gray */
    color: #6B7280; /* Darker gray text */
    transform: none;
    box-shadow: none;
    opacity: 1;
}

.btn-primary:disabled:hover,
.btn-primary[disabled]:hover {
    transform: none;
    box-shadow: none;
    background-color: #D1D5DB;
    color: #6B7280;
}

.btn-saving {
    position: relative;
    cursor: wait;
    color: transparent !important; /* Hide original text */
}

.btn-saving::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px; /* Spinner size */
    height: 20px; /* Spinner size */
    margin-top: -10px; /* Center spinner */
    margin-left: -10px; /* Center spinner */
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    font-weight: bold;
}

.btn-secondary:hover {
    background-color: var(--color-primary);
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background-image: linear-gradient(to right, #E53E3E, #C53030);
    color: #FFFFFF;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}

.btn-lg {
    font-size: 18px;
    padding: 15px 30px;
}

.theme-toggle {
    background-color: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
    border-radius: 50%;
}

.theme-toggle:hover {
    background-color: var(--color-border);
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--color-text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.nav-item:hover {
    background-color: var(--color-border);
}

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

.nav-icon {
    font-size: 18px;
}

.user-profile-link {
    display: block;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    text-decoration: none;
}

.user-profile {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 12px;
    flex-shrink: 0; /* Prevent shrinking */
}

.user-info {
    flex-grow: 1;
    overflow: hidden; /* Add this to contain the child */
}

.user-name {
    font-weight: 600;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--color-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.logout-link:hover {
    background-color: var(--color-border);
}

.content-frame {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.content-frame h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-top: 0;
    margin-bottom: 16px;
}

.content-frame p {
    font-size: 16px;
    color: var(--color-text-secondary);
    margin-bottom: 32px;
}
.toolbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-end;
}

.form-toggle {
    display: flex;
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.toggle-btn {
    flex-grow: 1;
    padding: 8px 16px;
    border: none;
    background-color: transparent;
    color: var(--color-text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

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

.toggle-btn.active {
    background-color: var(--color-primary);
    color: #FFFFFF;
}

#custom-settings {
    display: none;
}

.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark-mode .card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.card h3 {
    margin-top: 0;
    margin-bottom: 20px;
}

.empty-state {
    text-align: center;
    padding: 50px;
}

.toolbar {
    margin-bottom: 20px;
}

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

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--light-color-border);
}

th {
    background-color: var(--color-surface);
    font-weight: 600;
}

.status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background-color: #C6F6D5;
    color: #22543D;
}

.status-paused {
    background-color: #FEEBC8;
    color: #975A16;
}

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.alert-success {
    background-color: #C6F6D5;
    color: #22543D;
}

.alert-error {
    background-color: #FED7D7;
    color: #9B2C2C;
}

.hidden {
    display: none !important;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    font-size: 16px;
            box-sizing: border-box;
        }
        
        .form-control:focus {
            outline: none;
            border-color: var(--color-primary);
            box-shadow: 0 0 0 3px var(--color-primary-light);
        }
        
        .dark-mode .form-control {        background-color: var(--color-surface) !important;
        color: var(--color-text-primary) !important;
        border-color: var(--color-border) !important;
    }
    
/* Custom styling for the Load Template select dropdown */
#load_template {
    /* Hide default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Add custom arrow icon */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%236B7280' d='M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem; /* Make space for the custom arrow */
}

.dark-mode #load_template {
    /* Invert arrow color for dark mode */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%239CA3AF' d='M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z'/%3E%3C/svg%3E");
}

    .input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group p {
    flex-grow: 1;
    margin: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

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

.account-settings-card .form-group {
    margin-bottom: 20px;
}

.account-settings-card .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.account-settings-card h3 {
    margin-top: 30px;
    margin-bottom: 20px;
    font-size: 20px;
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
}

.account-settings-card h3:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex-grow: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 20px;
}

.form-actions button:not(:last-child) {
    margin-right: 10px;
}

.form-actions-stacked {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-container.centered-layout .sidebar {
    display: none;
}

.app-container.centered-layout .main-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.centered-layout .content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.centered-layout .logo-container {
    text-align: center;
}

.centered-layout .logo {
    max-width: 250px;
}

.centered-layout .card {
    width: 100%;
    max-width: 400px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.centered-layout .card h3 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
}

.centered-layout .card .subtext {
    text-align: center;
    color: var(--color-text-secondary);
    margin-bottom: 30px;
}

.centered-layout .form-group {
    margin-bottom: 20px;
}

.centered-layout .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.centered-layout .form-group input {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    font-size: 16px;
    box-sizing: border-box;
}

.centered-layout .form-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 30px;
}

.inbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.inbox-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.inbox-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dark-mode .inbox-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.template-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border); /* Added border */
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.05); /* Subtle initial shadow */
}

.template-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06); /* More pronounced hover shadow */
    transform: translateY(-2px); /* Slight lift effect */
}

.dark-mode .template-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1), 0 2px 4px rgba(255, 255, 255, 0.06);
}

.inbox-card-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.inbox-card-body {
    flex-grow: 1;
}

.inbox-email {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    word-break: break-all;
}

.inbox-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Template Card Internal Styling */
.template-card-header {
    margin-bottom: 5px;
}

.template-card-header .template-name {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--color-text-primary);
}

.template-card-body {
    flex-grow: 1;
    margin-bottom: 15px;
}

.template-card-body .template-subject {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}
/* End Template Card Internal Styling */

.btn-danger {
    background-color: #E53E3E;
    color: #FFFFFF;
    border: 1px solid #E53E3E;
}

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

.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
    background-color: var(--color-surface);
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid var(--color-border);
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 600px;
    border-radius: 12px;
    position: relative; /* Added for absolute positioning of close button */
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}


.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.btn-icon {
    padding: 0.5rem;
    font-size: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Template Modal Customization for Height and Width */
#template-modal .modal-content {
    margin: 5% auto; /* Move higher up the screen */
    max-width: 800px; /* Increase width for better form layout */
    max-height: 90vh; /* Limit max height to viewport height */
    overflow-y: auto; /* Enable scrolling for long content */
}

/* Inbox Settings Modal Customization for Height and Width */
#settings-modal .modal-content {
    margin: 5% auto; /* Move higher up the screen */
    max-width: 800px; /* Increase width for better form layout */
    max-height: 90vh; /* Limit max height to viewport height */
    overflow-y: auto; /* Enable scrolling for long content */
}

/* Delete Confirmation Modal Styling */
#delete-confirm-modal-template .modal-content {
    padding: 30px;
    text-align: center;
}

/* Ensure close button is correctly positioned */
#delete-confirm-modal-template .close-btn {
    position: absolute !important;
    top: 10px !important;
    right: 15px !important;
    z-index: 10 !important;
    display: block !important;
}

#delete-confirm-modal-template h2 {
    color: #E53E3E;
    margin-bottom: 10px;
}

#delete-confirm-modal-template p {
    color: var(--color-text-secondary);
    margin-bottom: 30px;
}

#delete-confirm-modal-template .form-actions {
    justify-content: center;
    /* Removed gap: 15px; */
}

/* Add spacing fallback */
#delete-confirm-modal-template #confirm-delete-template-btn {
    margin-left: 15px !important;
}
/* End Custom Delete Styling */

/* Fix for Inbox Delete Modal Spacing */
#delete-confirm-modal .form-actions {
    justify-content: center !important;
}

#delete-confirm-modal .delete-cancel-btn {
    margin-left: 15px !important;
}
/* End Custom Delete Styling */

/* Floating Notifications */
#notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.notification {
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.success {
    background-color: #4CAF50;
}

.notification.error {
    background-color: #f44336;
}

/* End Floating Notifications */

/* Tab Switch Styling for Modal */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 20px;
}

.tab-link {
    flex-grow: 0;
    padding: 10px 20px;
    border-radius: 0;
    border: none;
    background-color: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s;
    position: relative;
    margin-bottom: -2px; /* To overlap the border */
    font-size: 14px;
}

.tab-link:hover {
    color: var(--color-primary);
    background-color: transparent;
}

.tab-link.active {
    color: var(--color-primary);
    background-color: transparent;
}

.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-primary);
}

.tab-content {
    display: none;
}

/* Connection Type Selector */
.connection-type-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.connection-type-card,
.plan-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 0; /* Make cards equally share space */
    max-width: 250px; /* Set a max width for large screens */
    padding: 20px;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.connection-type-card:hover,
.plan-type-card:hover {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 10px rgba(144, 88, 239, 0.1);
}

.connection-type-card.active,
.plan-type-card.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(144, 88, 239, 0.3);
    background-color: rgba(144, 88, 239, 0.05); /* Light background tint */
}

.connection-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
    object-fit: contain;
}

/* Icon color for plan cards */
.plan-type-card .connection-icon {
    color: var(--color-primary); /* Purple in light mode */
}

.dark-mode .plan-type-card .connection-icon {
    color: #FFFFFF; /* Explicitly white in dark mode */
}

.connection-type-card h4,
.plan-type-card h4 {
    margin: 5px 0;
    font-size: 16px;
    color: var(--color-primary); /* Purple in light mode */
}

.dark-mode .plan-type-card h4 {
    color: #FFFFFF; /* Explicitly white in dark mode */
}

.connection-type-card p,
.plan-type-card p {
    margin: 0;
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* --- Plan Type Card Styling Enhancements --- */
.plan-type-card {
    background-color: var(--color-background);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.dark-mode .plan-type-card {
    background-color: var(--color-surface);
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.05);
}

.plan-type-card.active {
    /* Enhance active state */
    box-shadow: 0 0 20px rgba(144, 88, 239, 0.5);
    transform: scale(1.02); /* Subtle lift */
}
/* --- End Plan Type Card Styling Enhancements --- */

/* Custom icon size adjustment */
.connection-type-card[data-type="custom"] .connection-icon {
    width: 80px;
    height: 80px;
}

/* --- Styling Enhancements --- */

/* Modal Content Elevation */
.modal-content {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 30px;
}

/* Responsive Form Row */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* Connection Card Adjustments */
.connection-type-card h4 {
    font-weight: 700;
}

.connection-type-card p {
    font-size: 11px;
}

/* Link visibility fix for dark mode */
.form-text {
    display: block;
    margin-top: 5px;
    font-size: 85%;
}

.text-muted {
    color: var(--color-text-secondary);
}

.text-danger {
    color: #EF4444; /* A strong red */
    font-size: 0.875em; /* Smaller text */
    font-weight: 500; /* Slightly lighter than bold */
    margin-top: 4px; /* Space from input */
    display: block; /* Ensure it takes its own line */
}

.text-white {
    color: #FFFFFF;
}

/* Spin animation for loading state */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Shake animation for invalid input */
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.shake {
    animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.form-text a {
    color: var(--color-primary); /* Use primary color for visibility in light mode */
    text-decoration: underline;
}

.dark-mode .form-text a {
    color: var(--color-primary-light); /* Use a lighter color for dark mode */
}
/* --- Inbox List View Styles --- */
.view-toggle {
    display: flex;
    gap: 5px;
    margin-right: 15px;
}

.view-toggle .btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-background);
    color: var(--color-text-secondary);
}

.view-toggle .btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.inbox-list.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inbox-list.list-view .inbox-card {
    flex-direction: row;
    align-items: center;
    padding: 12px 20px;
}

.inbox-list.list-view .inbox-card-header {
    margin-bottom: 0;
    margin-left: auto; /* Push to right */
    order: 2;
    display: flex;
    align-items: center;
}

.inbox-list.list-view .inbox-card-body {
    flex-grow: 0; /* Don't expand infinitely */
    margin-right: 20px;
    order: 1;
    min-width: 250px;
}

.inbox-list.list-view .inbox-email {
    margin: 0;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-list.list-view .inbox-card-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    order: 3;
    display: flex;
    gap: 10px;
    margin-left: 20px;
}

/* Responsive fix for list view */
@media (max-width: 768px) {
    .inbox-list.list-view .inbox-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .inbox-list.list-view .inbox-card-header {
        margin-left: 0;
        margin-bottom: 10px;
        order: 0;
    }
    .inbox-list.list-view .inbox-card-body {
        margin-bottom: 10px;
        order: 1;
    }
    .inbox-list.list-view .inbox-card-footer {
        margin-left: 0;
        order: 2;
        width: 100%;
        justify-content: flex-end;
    }
}

/* Template Selection Grid (Restored) */
.template-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.template-selection-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background-color: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.template-selection-card:hover {
    border-color: var(--color-primary-light);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.template-selection-card.selected {
    border-color: var(--color-primary);
    background-color: rgba(144, 88, 239, 0.05);
    box-shadow: 0 0 10px rgba(144, 88, 239, 0.3);
}

.dark-mode .template-selection-card.selected {
    background-color: rgba(144, 88, 239, 0.15);
}

.template-selection-card .card-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    color: var(--color-text-primary);
}

.template-selection-card .card-header i {
    color: var(--color-primary);
    margin-right: 8px;
}

.template-selection-card .card-subject {
    font-size: 0.9em;
    color: var(--color-text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 28px;
}

.selection-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    color: var(--color-primary);
    font-size: 1.2em;
    display: none;
}

.template-selection-card.selected .selection-indicator {
    display: block;
}

/* Plan Type Selector (Restored) */
.plan-type-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.plan-type-card {
    flex: 1;
    background-color: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.plan-type-card:hover {
    border-color: var(--color-primary-light);
    transform: translateY(-2px);
    opacity: 1;
}

.plan-type-card.active {
    border-color: var(--color-primary);
    background-color: rgba(59, 130, 246, 0.05); /* Light blue tint */
    opacity: 1;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.plan-type-card i {
    font-size: 24px;
    color: var(--color-text-secondary);
    margin-bottom: 10px;
    display: block;
}

.plan-type-card.active i {
    color: var(--color-primary);
}

.plan-type-card h4 {
    margin: 0 0 5px 0;
    color: var(--color-text-primary);
    font-size: 16px;
}

.plan-type-card p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 12px;
}

/* --- Doughnut Chart Styles --- */
.landing-stats-container {
    display: flex;
    align-items: center;
    gap: 40px;
    padding: 20px;
    background-color: var(--color-bg);
    border-radius: 8px;
    justify-content: center;
}

.doughnut-chart {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    position: relative;
    /* Transformation handled by JS via inline style: background: conic-gradient(...) */
}

/* The white hole in the middle to make it a doughnut */
.doughnut-chart::after {
    content: "";
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: var(--color-bg);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--color-text-primary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-label {
    font-weight: 500;
}

.legend-value {
    color: var(--color-text-secondary);
    margin-left: auto;
}
