
/* Reset and Base Styles */
:root {
    --primary-color: rgb(238, 31, 59);
    --primary-darker-color: rgb(181, 23, 44);
    --secondary-color: rgb(229, 229, 247);
}

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

body {
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
    color: #000;
    line-height: 1.6;
    min-height: 100vh;
}

/* Background Pattern */
.bg {
    top: 0;
    left: 0;
    position: fixed;
    z-index: -1;
    width: 100%;
    height: 100vh;
    background-color: var(--secondary-color);
    opacity: 0.05;
    background: radial-gradient(circle, transparent 20%, var(--secondary-color) 20%, var(--secondary-color) 80%, transparent 80%, transparent), radial-gradient(circle, transparent 20%, var(--secondary-color) 20%, var(--secondary-color) 80%, transparent 80%, transparent) 25px 25px, linear-gradient(var(--primary-color) 2px, transparent 2px) 0 -1px, linear-gradient(90deg, var(--primary-color) 2px, var(--secondary-color) 2px) -1px 0;
    background-size: 50px 50px, 50px 50px, 25px 25px, 25px 25px;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header img {
    height: 5rem;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 1.8rem;
    color: var(--primary-darker-color);
}

/* User Info (shown when logged in) */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    font-size: 0.9rem;
    color: #666;
}

.user-info.hidden {
    display: none;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    text-align: center;
    background: white;
    padding: 48px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    width: 90%;
}

.login-card img {
    height: 4rem;
    margin-bottom: 24px;
}

.login-card h2 {
    font-size: 1.8rem;
    color: var(--primary-darker-color);
    margin-bottom: 12px;
}

.login-card p {
    color: #666;
    margin-bottom: 32px;
    line-height: 1.5;
}

.login-card .btn-login {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
}

.login-card .btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Tabs Navigation */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.card h2 {
    font-size: 1.4rem;
    color: var(--primary-darker-color);
    margin-bottom: 20px;
}

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

.card-header h2 {
    margin-bottom: 0;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

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

.form-group input[type="file"] {
    padding: 8px 0;
}

.form-group input::placeholder {
    color: #aaa;
}

#note {
    resize: vertical;
}

/* Password Field with Toggle and Generate */
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    padding-right: 100px;
}

.toggle-password,
.generate-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.toggle-password:hover,
.generate-password:hover {
    opacity: 1;
}

.generate-password {
    right: 50px;
}

.toggle-password {
    right: 10px;
}

.key-icon {
    font-family: monospace;
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.eye-icon {
    font-family: monospace;
    font-weight: bold;
    color: #666;
    font-size: 0.9rem;
}

/* Username Input Row with Client Email Button */
.username-input-row {
    position: relative;
    display: flex;
    align-items: center;
}

.username-input-row input {
    padding-right: 90px;
}

.use-client-email-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.use-client-email-btn:hover {
    opacity: 1;
}

.use-client-email-btn.hidden {
    display: none;
}

.use-client-phone-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.use-client-phone-btn:hover {
    opacity: 1;
}

.use-client-phone-btn.hidden {
    display: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--secondary-color);
}

.modal-header h3 {
    color: var(--primary-darker-color);
    font-size: 1.2rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--primary-color);
}

.modal-body {
    padding: 0;
}

/* Password Preview in Modal */
.password-preview {
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 10px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--primary-darker-color);
    letter-spacing: 1px;
    word-break: break-all;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-password-btn {
    display: block;
    margin: 0 auto 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    color: var(--primary-color);
    border-radius: 8px;
}

.refresh-password-btn:hover {
    opacity: 1;
    background: rgba(238, 31, 59, 0.1);
}

.refresh-password-btn:active {
    transform: scale(0.95);
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-darker-color);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: background 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-darker-color);
}

/* Checkbox Group */
.checkbox-group {
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label span {
    color: #555;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

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

.btn-primary:hover {
    background-color: var(--primary-darker-color);
}

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

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

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

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

/* Service Form */
.service-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px dashed var(--primary-color);
}

/* Search Bar */
.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-bar input::placeholder {
    color: #aaa;
}

.service-form.hidden {
    display: none;
}

.service-form h3 {
    margin-bottom: 16px;
    color: var(--primary-darker-color);
}

/* Service Grid */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.service-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    border: 2px solid #eee;
    transition: border-color 0.3s ease;
}

.service-card:hover {
    border-color: var(--primary-color);
}

.service-card .service-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 12px;
}

.service-card .service-logo-placeholder {
    width: 64px;
    height: 64px;
    background: #ddd;
    border-radius: 8px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #888;
}

.service-card h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--primary-darker-color);
}

.service-card .username-label {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 12px;
}

.service-card .service-actions {
    display: flex;
    justify-content: center;
}

/* Icon Button Styling */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--primary-color);
}

.icon-btn svg {
    display: block;
}

.icon-btn-danger {
    color: #e74c3c;
}

.icon-btn-danger:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

.empty-message {
    grid-column: 1 / -1;
    text-align: center;
    color: #888;
    padding: 40px;
}

/* Image Preview */
.image-preview {
    margin-top: 10px;
}

.image-preview img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.image-preview.hidden {
    display: none;
}

/* Client Details Section */
.client-details {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.client-details:hover {
    border-color: var(--primary-color);
}

.client-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f0f0f0;
    cursor: pointer;
    user-select: none;
}

.client-details-header h3 {
    margin: 0;
    color: var(--primary-darker-color);
    font-size: 1rem;
}

.toggle-client-details {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    color: var(--primary-darker-color);
}

.toggle-client-details:hover {
    opacity: 0.7;
}

.client-details.collapsed .toggle-client-details {
    transform: rotate(-90deg);
}

.client-details-content {
    padding: 20px;
    display: block;
}

.client-details.collapsed .client-details-content {
    display: none;
}

.client-details .form-group {
    margin-bottom: 16px;
}

.client-details .form-group:last-child {
    margin-bottom: 0;
}

/* Service Entry Cards */
#service-entries {
    margin-bottom: 16px;
}

.service-entry {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.service-entry:hover {
    border-color: var(--primary-color);
}

.service-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f0f0f0;
    cursor: pointer;
    user-select: none;
}

.service-entry-title {
    display: flex;
    align-items: center;
}

.service-entry-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-service-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
    margin-right: 12px;
}

.collapse-entry-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    color: var(--primary-darker-color);
}

.collapse-entry-btn:hover {
    opacity: 0.7;
}

.service-entry.collapsed .collapse-entry-btn {
    transform: rotate(-90deg);
}

.service-entry-number {
    font-weight: 600;
    color: var(--primary-darker-color);
    font-size: 1rem;
}

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

.service-entry-body {
    padding: 20px;
    display: block;
}

.service-entry.collapsed .service-entry-body {
    display: none;
}

.service-entry .form-group {
    margin-bottom: 16px;
}

.service-entry .form-group:last-child {
    margin-bottom: 0;
}

.remove-entry-btn {
    background: none;
    border: none;
    color: var(--primary-darker-color);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.remove-entry-btn:hover {
    opacity: 0.7;
}

.remove-entry-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.remove-entry-btn:disabled:hover {
    background: none;
}

.add-service-row {
    margin-bottom: 20px;
    text-align: center;
}

.add-service-row .btn {
    width: 100%;
}

/* Print Preview - Hidden by default */
.print-preview {
    display: none;
}

/* Print Styles */
@media print {
    /* Hide everything except the print preview */
    body * {
        visibility: hidden;
    }

    .print-preview,
    .print-preview * {
        visibility: visible;
    }

    .print-preview {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    /* Page container - fixed A4 dimensions */
    .print-page {
        width: 100%;
        height: 257mm; /* A4 height minus margins (297mm - 40mm for 0.8cm top/bottom) */
        max-height: 257mm;
        background: white;
        box-shadow: none;
        padding: 20px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Page Header with Logo and Company Info */
    .print-page-header {
        display: flex;
        align-items: flex-start;
        gap: 20px;
        margin-bottom: 15px;
    }

    .print-logo {
        height: 60px;
        width: auto;
        object-fit: contain;
    }

    .print-company-info {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .print-company-name {
        font-size: 1.1rem;
        font-weight: bold;
        color: var(--primary-darker-color);
        margin: 0 0 4px 0;
    }

    .print-company-address,
    .print-company-email,
    .print-company-phone {
        font-size: 0.85rem;
        color: #333;
        margin: 0;
        line-height: 1.4;
    }

    /* Divider */
    .print-divider {
        height: 2px;
        background-color: var(--primary-color);
        margin: 10px 0;
    }

    /* Services Grid Header with Date */
    .print-services-grid-header {
        display: flex;
        justify-content: flex-start;
        margin-bottom: 8px;
    }

    .print-date {
        font-size: 0.8rem;
        color: #333;
        font-weight: 500;
    }

    /* Client Details Section */
    .print-client-section {
        padding: 12px 0;
    }

    .print-client-title {
        font-size: 0.85rem;
        color: var(--primary-darker-color);
        margin: 0 0 8px 0;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .print-client-details {
        display: flex;
        flex-wrap: wrap;
        gap: 20px;
    }

    .print-client-field {
        display: flex;
        flex-direction: column;
        min-width: 180px;
    }

    .print-client-label {
        font-size: 0.7rem;
        color: #888;
        font-weight: 600;
        text-transform: uppercase;
    }

    .print-client-value {
        font-size: 0.95rem;
        color: #000;
        font-weight: 500;
    }

    /* Services Grid - 4 rows x 2 columns */
    .print-services-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr);
        gap: 10px;
        padding: 10px 0;
        flex: 1;
    }

    /* Service Card */
    .print-service-card {
        background: #f8f9fa;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        padding: 10px 12px;
        page-break-inside: avoid;
    }

    .print-service-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
        padding-bottom: 6px;
        border-bottom: 1px solid #ddd;
    }

    .print-service-logo {
        width: 28px;
        height: 28px;
        object-fit: contain;
        border-radius: 4px;
    }

    .print-service-name {
        font-size: 0.9rem;
        color: var(--primary-darker-color);
        margin: 0;
        font-weight: 600;
    }

    .print-service-fields {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .print-field-row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 8px;
    }

    .print-note-row {
        flex-direction: column;
        gap: 2px;
    }

    .print-label {
        font-size: 0.65rem;
        color: #666;
        font-weight: 600;
        text-transform: uppercase;
    }

    .print-value {
        font-size: 0.8rem;
        color: #000;
        word-break: break-all;
        text-align: right;
    }

    .print-note-row .print-value {
        text-align: left;
        font-size: 0.75rem;
        color: #555;
    }

    .print-password {
        font-family: 'Courier New', monospace;
        font-size: 0.75rem;
        letter-spacing: 1px;
    }

    /* Page Footer */
    .print-page-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-top: 1px solid #ddd;
        color: #888;
    }

    .print-page-footer small {
        font-size: 0.7rem;
    }

    .print-page-number {
        font-size: 0.75rem;
        color: #888;
    }

    /* Page settings */
    @page {
        size: A4;
        margin: 0.8cm;
    }

    /* Only add page break after if there's more content */
    .print-page:not(:last-child) {
        page-break-after: always;
    }

    /* Password character colors - for printing */
    .password-number {
        color: #2563eb !important;
    }

    .password-special {
        color: #dc2626 !important;
    }

    .password-letter {
        color: #000 !important;
    }
}

/* Password character colors - for screen display */
.password-number {
    color: #2563eb; /* Blue */
}

.password-special {
    color: #dc2626; /* Red */
}

.password-letter {
    color: #000; /* Black */
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--primary-darker-color);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: #e74c3c;
}

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

/* Disabled State Styling for Entry Fields */
.service-entry-body input:disabled,
.service-entry-body textarea:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #ced4da;
}

.service-entry-body input:disabled::placeholder {
    color: #adb5bd;
}

.toggle-password:disabled,
.generate-password:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.toggle-password:disabled:hover,
.generate-password:disabled:hover {
    opacity: 0.3;
}
