/* =============================================================================
   STYLESHEET V7: FINAL & COMPLETE
   This file contains all styles for the uktownandcity.com website.
   It is structured logically from base styles to page-specific components.
============================================================================= */

/* --- 1. SETUP & THEME VARIABLES --- */
:root {
    /* Dark Theme (Default) */
    --primary-color: #D8C3A5;
    --bg-color: #2D2D2D;
    --surface-color: #3A3A3A;
    --text-color: #EAEAEA;
    --heading-color: #FFFFFF;
    --border-color: #4A4A4A;
    --box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    --primary-color_focus: rgba(216, 195, 165, 0.3);

    /* Global */
    --border-radius: 4px;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Playfair Display', serif;
}

:root[data-theme="light"] {
    /* Light Theme Overrides */
    --primary-color: #8E795E;
    --bg-color: #F4F2EF;
    --surface-color: #FFFFFF;
    --text-color: #333333;
    --heading-color: #000000;
    --border-color: #E0E0E0;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --primary-color_focus: rgba(142, 121, 94, 0.25);
}

/* --- 2. BASE & TYPOGRAPHY --- */

html, body {
    overflow-x: hidden;
}

body { 
    margin: 0; 
    font-family: var(--font-body);
    background-color: var(--bg-color); 
    color: var(--text-color); 
    line-height: 1.7;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--heading-color);
    font-weight: 700;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}
:root[data-theme="dark"] a:hover {
    color: #fff;
}
:root[data-theme="light"] a:hover {
    color: #000;
}

/* --- 3. LAYOUT (HEADER, FOOTER, CONTAINERS) --- */
.main-header { 
    background-color: rgba(45, 45, 45, 0.8);
    border-bottom: 1px solid #4A4A4A;
    padding: 0 1.5rem; 
    position: sticky; 
    top: 0; 
    z-index: 1000;
    backdrop-filter: blur(10px);
}
:root[data-theme="light"] .main-header {
    background-color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid var(--border-color);
}

.nav-container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    max-width: 1200px; 
    margin: 0 auto; 
    height: 65px; 
    gap: 1rem;
}

.main-content { 
    max-width: 1200px; 
    margin: 3rem auto; 
    padding: 0 1.5rem; 
}

.page-container {
    max-width: 800px;
    margin: 0 auto;
}

.main-footer { 
    padding: 4rem 2rem; 
    margin-top: 4rem; 
    background-color: #222;
    border-top: 1px solid #4A4A4A; 
}
:root[data-theme="light"] .main-footer {
    background-color: #EAEAEA;
    border-top: 1px solid #D0D0D0;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
    color: #aaa;
}
:root[data-theme="light"] .footer-container {
    color: #555;
}

.footer-copyright {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid #4A4A4A;
    font-size: 0.9rem;
    color: #777;
}
:root[data-theme="light"] .footer-copyright {
    border-top: 1px solid #D0D0D0;
    color: #666;
}

/* --- 4. COMPONENTS (BUTTONS, FORMS, CARDS, ETC.) --- */

/* General Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: var(--font-body);
}
:root[data-theme="light"] .form-group input[type="text"],
:root[data-theme="light"] .form-group input[type="email"],
:root[data-theme="light"] .form-group input[type="password"],
:root[data-theme="light"] .form-group select,
:root[data-theme="light"] .form-group textarea {
    background-color: #fff;
    border-color: #ccc;
    color: #333;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color_focus);
}

/* Buttons */
.btn-primary {
    display: block;
    width: 100%;
    background-color: var(--primary-color);
    color: #000;
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 700;
    transition: background-color 0.2s, transform 0.2s;
}
:root[data-theme="light"] .btn-primary {
    color: #fff;
}
.btn-primary:hover {
    background-color: var(--heading-color);
    color: var(--bg-color);
}
.btn-primary:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    color: #888;
}

/* Navigation */
.nav-logo a { 
    color: var(--heading-color); 
    font-size: 1.25rem;
    font-family: var(--font-heading);
    white-space: nowrap;
}
.main-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.main-nav ul { 
    margin: 0; 
    padding: 0; 
    list-style: none; 
    display: flex; 
    align-items: center;
    gap: 1.5rem; 
}
.main-nav a { 
    color: var(--text-color); 
    font-size: 1rem;
    font-weight: 500;
    position: relative;
    padding-bottom: 5px;
}
.main-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.25s ease-out;
}
.main-nav a:hover::after, .main-nav a.active::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Theme Toggle */
#theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s;
}
#theme-toggle:hover {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
}
#theme-toggle .icon-sun, #theme-toggle .icon-moon {
    width: 20px;
    height: 20px;
}
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* Photo Cards */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2.5rem;
}
.photo-card {
    display: block;
    text-decoration: none;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.photo-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--box-shadow);
}
.photo-card figure {
    margin: 0;
}
.photo-card img, .photo-card picture {
    width: 100%;
    height: 250px;
    display: block;
    background-color: #ddd;
}
.photo-card img {
    object-fit: cover;
}
.photo-card figcaption {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
}
.photo-card-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--heading-color);
    margin-bottom: 0.25rem;
}
:root[data-theme="light"] .photo-card-title {
    color: #333;
}
.photo-card-user {
    font-size: 0.9rem;
    color: #bbb;
    display: block;
}
:root[data-theme="light"] .photo-card-user {
    color: #555;
}

/* Breadcrumbs */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    margin: 0 0 1.5rem 0;
    list-style: none;
    font-size: 0.95rem;
}
.breadcrumb-item {
    display: flex;
    align-items: center;
}
.breadcrumb-item + .breadcrumb-item::before {
    content: '>';
    display: inline-block;
    padding: 0 .5rem;
    color: var(--text-color);
    opacity: 0.5;
}
.breadcrumb-item a {
    color: var(--text-color);
    opacity: 0.8;
}
.breadcrumb-item a:hover {
    color: var(--primary-color);
    opacity: 1;
}
.breadcrumb-item.active {
    color: var(--heading-color);
    font-weight: 500;
}

/* --- 5. PAGE-SPECIFIC STYLES --- */

/* Login/Register Page */
.form-container h1 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1rem;
}
.form-container p {
    text-align: center;
    margin-top: 0;
    margin-bottom: 2.5rem;
    color: var(--text-color);
}
:root[data-theme="light"] .form-container p {
    color: #555;
}
.form-errors {
    background-color: #721c24;
    color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}
.form-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-color);
}
:root[data-theme="light"] .form-switch {
    color: #555;
}

/* Upload Page */
.location-search-container {
    position: relative;
}
.form-group input[type="file"] {
    padding: 10px;
    font-size: 0.95rem;
}
:root[data-theme="dark"] .form-group input[type="file"]::-webkit-file-upload-button {
    background: var(--surface-color);
    color: var(--text-color);
    border: none;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-right: 10px;
}
:root[data-theme="light"] .form-group input[type="file"]::-webkit-file-upload-button {
    background: #f0f0f0;
    color: var(--text-color);
    border: 1px solid #ccc;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-right: 10px;
}
#previews-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}
.preview-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}
:root[data-theme="light"] .preview-card {
    background-color: #fff;
}
.preview-image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background-color: var(--bg-color);
}
.preview-inputs {
    padding: 1rem;
}
.preview-inputs .form-group {
    margin-bottom: 0.75rem;
}
.preview-inputs label {
    font-size: 0.9rem;
}
.preview-inputs input,
.preview-inputs textarea {
    font-size: 0.95rem;
    padding: 8px;
}
.preview-inputs textarea {
    resize: vertical;
}
.upload-size-display {
    text-align: right;
    font-weight: 500;
    margin: -0.5rem 0 1rem 0;
    color: var(--text-color);
}
:root[data-theme="light"] .upload-size-display {
    color: #555;
}

/* Search & Autocomplete */
.search-bar-container {
    max-width: 1200px;
    margin: 2px auto 0; /* pushes it down 2px */
    padding: 0;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 100%; /* match parent width */
}
.search-form {
    width: 100%;
}
.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
        border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.2s ease;
}
:root[data-theme="light"] .search-input {
    background-color: #fff;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-color_focus);
}
.search-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.7;
}
:root[data-theme="light"] .search-button {
    color: #555;
}
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    z-index: 1001;
    max-height: 300px;
    overflow-y: auto;
}
:root[data-theme="light"] .autocomplete-results {
    background-color: #fff;
}
.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.autocomplete-item:last-child {
    border-bottom: none;
}
.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: var(--primary-color);
    color: #000;
}
:root[data-theme="light"] .autocomplete-item:hover,
:root[data-theme="light"] .autocomplete-item.active {
    color: #fff;
}
.autocomplete-item .county {
    opacity: 0.7;
    font-size: 0.9em;
}

/* Locations, Country, County Pages */
.locations-list .country-heading {
    font-size: 2rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}
.country-list-main, .county-list, .town-list {
    list-style: none;
    padding: 0;
}
.country-list-main {
    max-width: 600px;
    margin: 2rem auto;
}
.country-list-main li a {
    display: block;
    padding: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    font-family: var(--font-heading);
    transition: all 0.2s;
}
.country-list-main li a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--box-shadow);
}
.county-list, .town-list {
    column-count: 3;
    column-gap: 2rem;
}
.county-list li a, .town-list li a {
    display: block;
    padding: 0.75rem 0;
    font-size: 1.2rem;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.town-list .county-name {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-left: 0.25rem;
}
.county-list li a:hover, .town-list li a:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Search Results Page */
.search-results-list ul {
    list-style: none;
    padding: 0;
    max-width: 500px;
    margin: 1.5rem auto 0;
}
.search-results-list li a {
    display: block;
    padding: 1rem;
    font-size: 1.2rem;
    text-align: center;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    transition: all 0.2s;
}
.search-results-list li a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-3px);
}

/* Photo Detail Page */
.photo-detail-view {
    max-width: 1200px;
}
.photo-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.photo-header {
    text-align: left;
}
.photo-header h1 {
    font-size: 2.5rem;
    margin: 0;
}
.photo-meta {
    opacity: 0.8;
    font-size: 1.1rem;
    margin: 0;
}
.photo-meta a:hover {
    text-decoration: underline;
}
.photo-main {
    margin-bottom: 2rem;
}
.photo-main img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
}
.rating-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--surface-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}
:root[data-theme="light"] .rating-summary {
    background-color: #fff;
}
.avg-rating {
    font-weight: bold;
    font-size: 1.5rem;
}
.star-display {
    --percent: calc(var(--rating) / 5 * 100%);
    display: inline-block;
    font-size: 1.25rem;
    font-family: Times;
    line-height: 1;
}
.star-display::before {
    content: '★★★★★';
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--primary-color) var(--percent), var(--border-color) var(--percent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.rating-count {
    font-size: 0.9rem;
    opacity: 0.8;
}
.rating-form-container {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}
:root[data-theme="light"] .rating-form-container {
    background-color: #fff;
}
.rating-form fieldset {
    border: none;
    padding: 0;
    margin: 0;
}
.rating-form legend {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--heading-color);
}
.star-rating-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 0.25rem;
}
.star-rating-input input { 
    display: none; 
}
.star-rating-input label {
    font-size: 2.5rem;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s, transform 0.1s;
}
.star-rating-input label:hover {
    transform: scale(1.1);
}
.star-rating-input input:checked ~ label,
.star-rating-input label:hover,
.star-rating-input label:hover ~ label {
    color: var(--primary-color);
}
.photo-info {
    max-width: 800px;
    margin: 0 auto;
}
.photo-description h2,
.photo-comments h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}
.photo-description p {
    white-space: pre-wrap;
}
.photo-comments {
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border-color);
}
.comment-form .form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}
.comment-form button {
    display: inline-block;
    width: auto;
}
.comment-form button[type="button"] {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}
.comment-form button[type="button"]:hover {
    background-color: var(--surface-color);
    border-color: var(--text-color);
}
.comment-thread {
    list-style: none;
    padding: 0;
    margin-top: 2rem;
}
.comment-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
:root[data-theme="light"] .comment-item {
    background-color: #fff;
}
.comment-item .comment-item {
    margin-top: 1rem;
    background: var(--bg-color);
}
:root[data-theme="light"] .comment-item .comment-item {
    background: #f9f9f9;
}
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}
.comment-header strong a {
    font-weight: 600;
}
.comment-date {
    font-size: 0.85rem;
    opacity: 0.7;
}
.comment-body {
    white-space: pre-wrap;
}
.reply-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    cursor: pointer;
    padding: 4px 10px;
    font-size: 0.85rem;
    margin-top: 0.75rem;
    transition: all 0.2s;
}
.reply-btn:hover {
    background: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}
:root[data-theme="light"] .reply-btn:hover {
    color: #fff;
}

/* --- 6. RESPONSIVE & MOBILE STYLES --- */

/* Tablet & Larger Mobile Styles */
@media (max-width: 992px) {
    .nav-container {
        flex-wrap: wrap;
    }
    .search-container {
        order: 3;
        width: 100%;
        margin-top: 0.75rem;
        margin-bottom: 0.75rem;
        padding: 0;
    }
    .search-input {
        width: 100%;
        border-radius: var(--border-radius);
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .main-nav-links {
        display: none;
    }
    #mobile-menu {
        display: flex;
        position: fixed;
        top: 65px;
        left: 0;
        width: 100%;
        height: calc(100vh - 65px);
        background-color: var(--bg-color);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transform: translateX(100%);    
        overflow-x: hidden;
        transition: transform 0.3s ease-in-out;
        z-index: 999;
    }
    #mobile-menu.open {
        transform: translateX(0);
    }
    #mobile-menu .main-nav-links {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }
    #mobile-menu .main-nav-links a {
        font-size: 1.5rem;
        font-weight: 700;
        padding: 0.5rem 1rem;
    }
    #mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 24px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1000;
    }
    #mobile-menu-toggle .bar {
        display: block;
        width: 30px;
        height: 3px;
        background-color: var(--text-color);
        border-radius: 3px;
        transition: all 0.3s ease-in-out;
    }
    #mobile-menu-toggle.open .bar:nth-child(1) {
        transform: rotate(45deg) translate(7px, 7px);
    }
    #mobile-menu-toggle.open .bar:nth-child(2) {
        opacity: 0;
    }
    #mobile-menu-toggle.open .bar:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }
    .no-scroll {
        overflow: hidden;
    }
    .county-list, .town-list { 
        column-count: 2; 
    }
    .photo-title-bar {
        flex-direction: column;
        align-items: center;
    }
    .photo-header {
        text-align: center;
    }

    /* NEW: Make photo on detail page wider on mobile */
    .photo-main {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
    }
    .photo-main img {
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .county-list, .town-list { 
        column-count: 1; 
    }
}
