/* CSS Variables for theming */
:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --text-secondary: #6c757d;
    --card-bg: #f8f9fa;
    --border-color: #e0e0e0;
    --primary-color: #007c89;
    --primary-hover: #006570;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --accent-color: #28a745;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --card-bg: #2d2d2d;
    --border-color: #404040;
    --primary-color: #00a0b0;
    --primary-hover: #008a9a;
    --secondary-color: #8a8a8a;
    --accent-color: #4caf50;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    color: var(--primary-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--card-bg);
    transform: scale(1.1);
}

/* Navigation Dropdown */
.app-nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropdown-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-dropdown-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 250px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.nav-dropdown-menu.show {
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.nav-item:last-child {
    border-bottom: none;
}

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

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

.nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.logout-btn {
    color: var(--danger-color);
    text-decoration: none;
    padding: 8px 16px;
    border: 2px solid var(--danger-color);
    border-radius: 5px;
    transition: all 0.3s ease;
}

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

/* Login Card */
.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 500px;
    margin: 50px auto;
}

.login-card h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-card p {
    margin-bottom: 30px;
    color: var(--secondary-color);
}

.login-form {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

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

.form-group input, .form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.features {
    text-align: left;
}

.features h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.features ul {
    list-style-position: inside;
    color: var(--secondary-color);
}

.features li {
    margin-bottom: 8px;
}

/* Dashboard */
.dashboard {
    display: grid;
    gap: 30px;
}

.section {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.section h2, .section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.location-select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
}

/* Tax Toggle */
.tax-section {
    margin-bottom: 30px;
}

.tax-toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.tax-info {
    font-size: 0.9em;
    color: var(--text-secondary);
    background-color: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    margin-top: 15px;
}

.tax-info a {
    color: var(--primary-color);
    text-decoration: none;
}

.tax-info a:hover {
    text-decoration: underline;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.tax-rate {
    padding: 15px;
    background-color: var(--bg-color);
    border-radius: 5px;
    border: 2px solid var(--border-color);
}

.tax-rate label {
    font-weight: 600;
    margin-right: 10px;
}

#currentTaxRate {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Address Form */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
}

.primary-btn, .secondary-btn, button[type="submit"] {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.primary-btn, button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover, button[type="submit"]:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

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

.secondary-btn:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 50px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 5px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background-color: var(--success-color);
}

.notification.error {
    background-color: var(--danger-color);
}

.notification.warning {
    background-color: var(--warning-color);
    color: #333;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .login-card {
        margin: 20px auto;
        padding: 30px 20px;
    }

    .app-intro {
        margin: 1rem 0;
        padding: 1.5rem;
    }

    .app-intro h1 {
        font-size: 2rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* App Header */
.app-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.back-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* App Introduction */
.app-intro {
    background: var(--card-bg);
    margin: 2rem 0;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.app-intro h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.app-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.app-description h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.app-description ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.app-description li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.install-prompt {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    text-align: center;
}

.install-prompt p {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.install-prompt small {
    color: var(--text-secondary);
}

/* Footer Styles */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-copyright {
    margin-bottom: 1rem;
}

.footer-copyright a {
    color: var(--accent-color);
    text-decoration: none;
}

.footer-copyright a:hover {
    text-decoration: underline;
}

.footer-links {
    font-size: 0.9rem;
}

.footer-links a {
    color: #ccc;
    text-decoration: none;
    margin: 0 0.5rem;
}

.footer-links a:hover {
    color: white;
    text-decoration: underline;
}

/* Setup Help Button */
.setup-help {
    text-align: center;
    margin-bottom: 1.5rem;
}

.help-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.help-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 124, 137, 0.3);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 2% auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: var(--primary-color);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.setup-section {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.setup-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setup-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.setup-section h4 {
    color: var(--text-color);
    margin: 1rem 0 0.5rem 0;
    font-size: 1rem;
}

.step-details {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.step-details ol, .step-details ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.step-details li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.step-details code {
    background: var(--card-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.permissions-box {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.permissions-box h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.permissions-box ul {
    margin-bottom: 1rem;
}

.permissions-box code {
    background: var(--bg-color);
    font-weight: bold;
}

.url-helper, .security-note, .troubleshooting {
    background: var(--card-bg);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 0 8px 8px 0;
}

.security-note {
    border-left-color: var(--warning-color);
}

.troubleshooting {
    border-left-color: var(--danger-color);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 85vh;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .step-details {
        padding: 0.75rem;
    }

    .permissions-box {
        padding: 0.75rem;
    }
}