/* CSS Variables for theming */
:root {
    /* Light Theme Colors (Adjusted for less brightness and lighter borders) */
    --bg-color: #e8e8ed; /* Slightly darker background */
    --container-bg: #f5f5f7; /* Off-white container */
    --header-bg: rgba(245, 245, 247, 0.85); /* Semi-transparent off-white for glass effect */
    --header-border: #e0e0e5; /* Lighter header border and location item separator */
    --text-color: #1c1c1e;
    --secondary-text-color: #3a3a3c;
    --tertiary-text-color: #636366;
    --tab-bar-bg: #e8e8ed; /* Matches overall background */
    --tab-bar-border: #d1d1d6;
    --tab-button-inactive-color: #8e8e93;
    --tab-button-active-bg: #ffffff; /* Active tab remains white */
    --tab-button-active-color: #007aff;
    --tab-button-active-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 0 0 0.5px #d1d1d6;
    --card-bg: #ffffff; /* Cards remain white for contrast */
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --card-border: #f2f2f7; /* Lighter card border */
    --input-bg: #e8e8ed; /* Matches overall background */
    --input-border: #c7c7cc; /* Softer input border */
    --input-focus-bg: #ffffff;
    --input-focus-border: #007aff;
    --input-focus-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
    --button-bg: #007aff;
    --button-color: #ffffff;
    --button-active-bg: #005bb5;
    --footer-bg: #e8e8ed; /* Matches overall background */
    --footer-border: #d1d1d6;
    --footer-text-color: #8e8e93;
    --modal-overlay-bg: rgba(0, 0, 0, 0.4);
    --modal-content-bg: #ffffff;
    --modal-title-color: #1c1c1e;
    --modal-message-color: #3a3a3c;
    --modal-button-bg: #007aff;
    --modal-button-color: #ffffff;
    --modal-button-active-bg: #005bb5;
    --header-box-bg: #e8e8ed; /* Background for the title/icon box */
    --header-box-border: #d1d1d6; /* Border for the title/icon box */
    --wheel-icon-color: #007aff; /* Color for the wheel icon */
    --location-icon-color: #007aff; /* Color for location phone/map icons */
    --schedule-box-bg: #e0e0e5; /* Background for the schedule box */
    --schedule-box-color: #3a3a3c; /* Text color for the schedule box */
    --slider-arrow-bg: rgba(0, 0, 0, 0.4);
    --slider-arrow-color: #ffffff;
    --slider-dot-inactive: #c7c7cc;
    --slider-dot-active: #007aff;
    --service-item-bg-light: #f2f2f7; /* Light background for service items */
    --service-item-bg-dark: #3a3a3c; /* Dark background for service items */
    --service-item-text-light: #1c1c1e;
    --service-item-text-dark: #e0e0e0;

    /* Theme Toggle Highlight Colors */
    --theme-toggle-highlight-bg-light: #007aff;
    --theme-toggle-highlight-color-light: #ffffff;
    --theme-toggle-highlight-shadow-light: 0 1px 3px rgba(0, 0, 0, 0.15), inset 0 0 0 0.5px rgba(0, 0, 0, 0.1);

    --theme-toggle-highlight-bg-dark: #0a84ff;
    --theme-toggle-highlight-color-dark: #ffffff;
    --theme-toggle-highlight-shadow-dark: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 0 0 0.5px rgba(255, 255, 255, 0.1);
}

/* Dark Theme Colors */
body.dark-mode {
    --bg-color: #1c1c1e; /* Dark background */
    --container-bg: #2c2c2e; /* Darker container */
    --header-bg: rgba(44, 44, 46, 0.85); /* Semi-transparent for glass effect */
    --header-border: #4a4a4d; /* Lighter header border and location item separator for dark mode */
    --text-color: #ffffff; /* White text */
    --secondary-text-color: #e0e0e0;
    --tertiary-text-color: #a0a0a0;
    --tab-bar-bg: #3a3a3c;
    --tab-bar-border: #505050;
    --tab-button-inactive-color: #a0a0a0;
    --tab-button-active-bg: #1c1c1e;
    --tab-button-active-color: #0a84ff; /* iOS dark mode blue */
    --tab-button-active-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), inset 0 0 0 0.5px #505050;
    --card-bg: #2c2c2e;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    --card-border: #3a3a3c; /* Lighter card border for dark mode */
    --input-bg: #3a3a3c;
    --input-border: #505050;
    --input-focus-bg: #2c2c2e;
    --input-focus-border: #0a84ff;
    --input-focus-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
    --button-bg: #0a84ff;
    --button-color: #ffffff;
    --button-active-bg: #006ee6;
    --footer-bg: #2c2c2e;
    --footer-border: #3a3a3c;
    --footer-text-color: #a0a0a0;
    --modal-overlay-bg: rgba(0, 0, 0, 0.6);
    --modal-content-bg: #2c2c2e;
    --modal-title-color: #ffffff;
    --modal-message-color: #e0e0e0;
    --modal-button-bg: #0a84ff;
    --modal-button-color: #ffffff;
    --modal-button-active-bg: #006ee6;
    --header-box-bg: #3a3a3c; /* Dark background for the title/icon box */
    --header-box-border: #505050; /* Dark border for the title/icon box */
    --wheel-icon-color: #0a84ff; /* Dark mode color for the wheel icon */
    --location-icon-color: #0a84ff; /* Color for location phone/map icons */
    --schedule-box-bg: #3a3a3c; /* Background for the schedule box */
    --schedule-box-color: #e0e0e0; /* Text color for the schedule box */
    --slider-arrow-bg: rgba(255, 255, 255, 0.2);
    --slider-arrow-color: #ffffff;
    --slider-dot-inactive: #505050;
    --slider-dot-active: #0a84ff;
    --service-item-bg-light: #3a3a3c; /* Dark background for service items */
    --service-item-bg-dark: #3a3a3c; /* Dark background for service items */
    --service-item-text-light: #e0e0e0;
    --service-item-text-dark: #ffffff;
}

/* General Styling using CSS Variables */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease; /* Smooth theme transition */
}

.ios-app-container {
    background-color: var(--container-bg);
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;

    transition: background-color 0.3s ease, box-shadow 0.3s ease;

    @media (max-width: 640px) {
        border-radius: 0;
        height: 100vh;
        max-width: 100%;
    }
}

.header {
    background-color: var(--header-bg);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--header-border);
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-box {
    background-color: var(--header-box-bg);
    padding: 0.3rem 0.6rem;
    border-radius: 0.6rem;
    border: 0.5px solid var(--header-box-border);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-box h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    transition: color 0.3s ease;
    margin: 0;
    padding: 0;
}

.header-right {
    display: flex;
    gap: 0.4rem;
}

.header-icon-button,
.theme-toggle-button {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--tertiary-text-color);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 0.5rem;
    transition: color 0.3s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon-button:hover,
.theme-toggle-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}
body.dark-mode .header-icon-button:hover,
body.dark-mode .theme-toggle-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Highlight style for theme toggle button */
.theme-toggle-highlight {
    background-color: var(--theme-toggle-highlight-bg-light);
    color: var(--theme-toggle-highlight-color-light);
    box-shadow: var(--theme-toggle-highlight-shadow-light);
}

body.dark-mode .theme-toggle-highlight {
    background-color: var(--theme-toggle-highlight-bg-dark);
    color: var(--theme-toggle-highlight-color-dark);
    box-shadow: var(--theme-toggle-highlight-shadow-dark);
}

.wheel-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    animation: rotateWheel 4s linear infinite;
    transition: fill 0.3s ease;
}

.wheel-icon path {
    fill: var(--wheel-icon-color);
    transition: fill 0.3s ease;
}

@keyframes rotateWheel {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.main-scroll-content {
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--container-bg);
    transition: background-color 0.3s ease;
}

.tab-bar {
    display: flex;
    justify-content: space-around;
    background-color: var(--tab-bar-bg);
    padding: 0.3rem 0.5rem;
    margin: 1.275rem 1rem 0.5rem; /* Adjusted margin-top to be 70% larger */
    border-radius: 0.75rem;
    box-shadow: inset 0 0 0 0.5px var(--tab-bar-border);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.tab-button {
    flex: 1;
    padding: 0.4rem 0.3rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--tab-button-inactive-color);
    text-align: center;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.tab-button.active {
    background-color: var(--tab-button-active-bg);
    color: var(--tab-button-active-color);
    box-shadow: var(--tab-button-active-shadow);
}

.content-section {
    padding: 1.5rem 1rem;
    background-color: var(--container-bg);
    transition: background-color 0.3s ease;
}

.content-section h2 { /* Targeting the "Мережа шиномонтажів у Рівному" heading */
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem; /* Kept from mb-4 */
    color: var(--text-color);
    transition: color 0.3s ease;
    margin-top: 0.75rem; /* Added margin-top to balance spacing */
}

.card {
    background-color: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--card-shadow);
    border: 0.5px solid var(--card-border);
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card h2 { /* This rule is for h2 inside cards, not the main heading */
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    transition: color 0.3s ease;
}

.card p, .card ul {
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    line-height: 1.5;
    transition: color 0.3s ease;
}

.card ul {
    list-style: none;
    padding: 0;
}

.card ul li {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.card ul li i {
    color: var(--tab-button-active-color);
    margin-right: 0.5rem;
    transition: color 0.3s ease;
}

/* Location specific styles */
.location-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 0.5px solid var(--header-border);
}

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

.location-info {
    flex-grow: 1;
}

.location-info p {
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 0.2rem;
}

.schedule-box {
    background-color: var(--schedule-box-bg);
    color: var(--schedule-box-color);
    padding: 0.25rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    display: inline-block;
    margin-top: 0.4rem;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-weight: 500;
}


.location-actions {
    display: flex;
    gap: 0.5rem;
}

.location-action-button {
    background: none;
    border: none;
    font-size: 1.5rem; /* Increased font-size for larger icons */
    color: var(--location-icon-color);
    cursor: pointer;
    padding: 0.7rem; /* Adjusted padding to match the increased font size */
    border-radius: 0.5rem;
    transition: color 0.3s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex; /* Ensure flex for centering icon */
    align-items: center; /* Center icon vertically */
    justify-content: center; /* Center icon horizontally */
}

.location-action-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}
body.dark-mode .location-action-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}


.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--tertiary-text-color);
    margin-bottom: 0.3rem;
    transition: color 0.3s ease;
}

.form-group input,
.form-group textarea,
.form-group select { /* Added select to styling */
    width: 100%;
    padding: 0.75rem 1rem;
    border: 0.5px solid var(--input-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    color: var(--text-color);
    background-color: var(--input-bg);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
    -webkit-appearance: none;
    height: 2.75rem; /* Increased height for consistent sizing and to prevent clipping */
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { /* Added select to styling */
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: var(--input-focus-shadow);
    background-color: var(--input-focus-bg);
}

.ios-button {
    display: block;
    width: 100%;
    padding: 0.85rem 1.5rem;
    background-color: var(--button-bg);
    color: var(--button-color);
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, color 0.3s ease;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.ios-button:active {
    background-color: var(--button-active-bg);
    transform: scale(0.99);
}

.footer {
    background-color: var(--footer-bg);
    padding: 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--footer-text-color);
    border-top: 1px solid var(--footer-border);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Custom Modal Styling */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--modal-overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--modal-content-bg);
    border-radius: 14px;
    padding: 1.5rem;
    width: 90%;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--modal-title-color);
    transition: color 0.3s ease;
}

.modal-content p {
    font-size: 0.95rem;
    color: var(--modal-message-color);
    margin-bottom: 1.25rem;
    transition: color 0.3s ease;
}

.modal-button {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--modal-button-bg);
    color: var(--modal-button-color);
    border: none;
    border-radius: 0.6rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.modal-button:active {
    background-color: var(--modal-button-active-bg);
}

/* Services Grid Specific Styles */
.services-grid {
    margin-top: 1rem; /* Add some top margin to separate from heading */
}

/* Adjust padding for the card in the services section to align content */
#services .card,
#appointment .card { /* Apply to both services and appointment cards */
    padding-left: 0.5rem; /* Match horizontal padding of tab bar buttons */
    padding-right: 0.5rem; /* Match horizontal padding of tab bar buttons */
    padding-top: 1.25rem; /* Keep existing top padding */
    padding-bottom: 1.25rem; /* Keep existing bottom padding */
}

.service-item {
    background-color: var(--service-item-bg-light);
    color: var(--service-item-text-light);
    padding: 0.75rem 1rem; /* Adjusted padding for better text fit */
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
    text-align: left; /* Ensure text aligns left within its box */
}

body.dark-mode .service-item {
    background-color: var(--service-item-bg-dark);
    color: var(--service-item-text-dark);
}

.service-item i {
    color: var(--tab-button-active-color); /* Use the accent blue for icons */
    margin-right: 0.75rem;
    font-size: 1.1rem; /* Slightly larger icon in service item */
    flex-shrink: 0; /* Prevent icon from shrinking */
}

.service-item span {
    flex-grow: 1; /* Allow text to take available space and wrap */
    word-break: break-word; /* Ensure long words break */
}
