@import url('fonts.css');

:root {
    --primary-green: #2ecc71;
    --dark-green: #27ae60;
    --light-green: #e8f5e9;
    --text-dark: #333;
    --gray-bg: #f9f9f9;
    --border-color: #ddd;
    --shadow-sm: 0 2px 15px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 5px 20px rgba(46, 204, 113, 0.3);
    --radius: 8px;
    --radius-lg: 12px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: var(--light-green);
    color: var(--dark-green);
}

.alert-error,
.alert-danger {
    background: #fee;
    color: #c33;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

.input-error {
    border-color: #c33 !important;
}

.field-error {
    color: #c33;
    font-size: 13px;
    margin-top: 6px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    background-color: var(--primary-green);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    background-color: var(--dark-green);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn-secondary {
    background: #95a5a6;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
}

.btn-danger:hover {
    background: #c0392b;
}

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

.btn-block {
    width: 100%;
}

/* Layout */
header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 12px 0;
}

header.is-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.logo img {
    height: 64px;
    width: auto;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.site-link {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.site-link:hover {
    color: var(--dark-green);
    text-decoration: underline;
}

.logout-btn {
    background: var(--primary-green);
    color: #fff;
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.logout-btn:hover {
    background: var(--dark-green);
}

.container {
    max-width: 1200px;
    margin: 24px auto 40px;
    padding: 0 16px;
}

.container-narrow {
    max-width: 800px;
}

.page-title {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin: 0 0 24px;
}

/* Auth pages */
.page-auth {
    background: linear-gradient(135deg, var(--light-green) 0%, #fff 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-container {
    background: #fff;
    padding: clamp(24px, 5vw, 40px);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(46, 204, 113, 0.15);
    width: 100%;
    max-width: 450px;
}

.login-container .logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-container .logo img {
    height: clamp(72px, 18vw, 100px);
}

.login-container h1 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    text-align: center;
    margin: 0 0 8px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin: 0 0 24px;
    font-size: 14px;
}

.text-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 500;
}

.text-link:hover {
    text-decoration: underline;
}

/* Client dashboard */
.page-dashboard {
    background-color: var(--gray-bg);
    min-height: 100vh;
}

.welcome-card {
    background: linear-gradient(135deg, var(--primary-green), var(--dark-green));
    color: #fff;
    padding: clamp(20px, 4vw, 30px);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.welcome-card h1 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    margin: 0 0 8px;
}

.welcome-card p {
    margin: 0;
    opacity: 0.95;
}

.info-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: clamp(20px, 4vw, 30px);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.info-card:last-child {
    margin-bottom: 0;
}

.info-card h2 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.25rem;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--light-green);
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: #666;
    font-weight: 500;
}

.info-value {
    font-weight: 600;
    text-align: right;
}

.cleanings-badge {
    display: inline-block;
    background: var(--light-green);
    color: var(--dark-green);
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
}

/* Admin */
.page-admin {
    background-color: var(--gray-bg);
    min-height: 100vh;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: stretch;
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    flex: 1;
    gap: 8px;
    min-width: min(100%, 280px);
    max-width: 420px;
}

.search-form input {
    flex: 1;
    min-width: 0;
}

.clients-table {
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.clients-table th {
    background: var(--primary-green);
    color: #fff;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    white-space: nowrap;
}

.clients-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.clients-table tr:last-child td {
    border-bottom: none;
}

.clients-table tbody tr:hover {
    background: var(--light-green);
}

.client-object-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 13px;
    margin-bottom: 8px;
    color: #666;
}

.client-object-line:last-child {
    margin-bottom: 0;
}

.client-object-line strong {
    color: var(--text-dark);
}

.client-object-line__expired {
    color: #b45309;
    font-weight: 600;
}

.client-row {
    cursor: pointer;
}

.client-row:focus-visible,
.client-card:focus-visible {
    outline: 2px solid var(--primary-green);
    outline-offset: -2px;
}

.objects-count {
    white-space: nowrap;
    font-size: 14px;
}

.page-header {
    margin-bottom: 8px;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--primary-green);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

.page-subtitle {
    margin: -8px 0 20px;
    color: #666;
    font-size: 14px;
}

.objects-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 20px;
    align-items: start;
}

.objects-form-card,
.objects-list-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: clamp(16px, 3vw, 24px);
    box-shadow: var(--shadow-sm);
}

.objects-form-card h2,
.objects-list-card h2 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.1rem;
    margin: 0 0 16px;
}

@media (max-width: 900px) {
    .objects-layout {
        grid-template-columns: 1fr;
    }
}

.detail-meta {
    margin-bottom: 16px;
}

.detail-meta__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: #666;
}

.detail-meta__row span:last-child {
    color: var(--text-dark);
    font-weight: 500;
    text-align: right;
}

.detail-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.detail-section-title {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    margin: 0 0 12px;
}

.detail-objects {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-objects__empty {
    padding: 24px 12px;
}

.detail-object {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
}

.detail-object__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.detail-object__row {
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
}

.detail-object__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.object-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.object-status--active {
    background: var(--light-green);
    color: var(--primary-green);
}

.object-status--expired {
    background: #fef3c7;
    color: #b45309;
}

.client-card__object {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #999;
}

/* Mobile client cards */
.client-cards {
    display: none;
}

.client-card {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.client-card:last-child {
    border-bottom: none;
}

.client-card__name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
}

.client-card__row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 6px;
    color: #666;
}

.client-card__row span:last-child {
    color: var(--text-dark);
    font-weight: 500;
    text-align: right;
}

.client-card__actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.client-card__actions .btn,
.client-card__actions form {
    flex: 1;
}

.client-card__actions .btn,
.client-card__actions button {
    width: 100%;
}

/* Modal */
.modal-overlay {
    --modal-duration: 0.25s;

    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity var(--modal-duration) ease,
        visibility 0s linear var(--modal-duration);
}

.modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition:
        opacity var(--modal-duration) ease,
        visibility 0s linear 0s;
}

.modal {
    background: #fff;
    padding: clamp(20px, 4vw, 30px);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0;
    transform: scale(0.96) translateY(10px);
    transition:
        opacity var(--modal-duration) ease,
        transform var(--modal-duration) ease;
}

.modal--wide {
    max-width: 640px;
}

.modal-overlay.is-active .modal {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.modal h2 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1.25rem;
    margin: 0 0 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.modal-actions .btn {
    flex: 1;
}

body.modal-open {
    overflow: hidden;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 14px;
}

.pagination .active span {
    background: var(--primary-green);
    color: #fff;
    border-color: var(--primary-green);
}

/* Responsive */
@media (max-width: 768px) {
    .logo img {
        height: 52px;
    }

    .clients-table table {
        display: none;
    }

    .client-cards {
        display: block;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form {
        max-width: none;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }
}

@media (max-width: 600px) {
    .info-row {
        flex-direction: column;
    }

    .info-value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 0 12px;
    }

    .container {
        padding: 0 12px;
        margin-top: 16px;
    }

    .logout-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    .btn:hover {
        transform: none;
    }
}
