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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 32px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.header-text {
    flex: 1;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    letter-spacing: -0.025em;
}

header p {
    font-size: 0.95rem;
    opacity: 0.85;
    margin: 0;
    font-weight: 400;
}

.header-download {
    flex-shrink: 0;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.form-section {
    width: 420px;
    padding: 0;
    background: #fafbfc;
    overflow-y: auto;
    border-right: 1px solid #e1e5e9;
}

/* Authentication Modal */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.auth-modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-modal-header h2 {
    color: #1a202c;
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.auth-modal-header p {
    color: #666;
    margin: 0;
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.auth-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.auth-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-content input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.auth-content input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-content button {
    padding: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s ease;
}

.auth-content button:hover {
    background: #5a67d8;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.google-signin-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #dadce0;
}

.auth-divider span {
    padding: 0 16px;
    color: #5f6368;
    font-size: 12px;
    text-transform: uppercase;
}

.auth-status {
    font-size: 13px;
    text-align: center;
    margin: 0;
    padding: 8px;
    border-radius: 4px;
}

.auth-status.error {
    color: #e53e3e;
    background: #fed7d7;
}

.auth-status.success {
    color: #38a169;
    background: #c6f6d5;
}

/* User Section */
.user-section {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e1e5e9;
    margin: 0;
}

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

.user-info p {
    margin: 0;
    color: #555;
    font-size: 14px;
}

#logoutBtn {
    padding: 6px 12px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

#logoutBtn:hover {
    background: #c53030;
}

/* Hide main content when modal is active */
.auth-modal.active ~ .main-content {
    filter: blur(3px);
    pointer-events: none;
}

.storage-controls {
    background: white;
    padding: 20px 24px;
    border-bottom: 1px solid #e1e5e9;
    margin: 0;
}

.storage-controls h3 {
    color: #1a202c;
    margin: 0 0 16px 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #718096;
}

.save-section {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.save-section input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.save-section input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.storage-controls button {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.storage-controls button:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.storage-controls select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 8px;
    background: white;
}

.button-row {
    display: flex;
    gap: 8px;
}

.button-row button {
    flex: 1;
}

.form-content {
    padding: 24px;
}

.form-section h2 {
    color: #1a202c;
    margin: 0 0 24px 0;
    font-size: 1.125rem;
    font-weight: 600;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.form-row .form-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
}

input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: white;
    font-family: inherit;
}

input::placeholder, textarea::placeholder {
    color: #9ca3af;
    font-style: italic;
    opacity: 0.8;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    height: 80px;
    resize: vertical;
    line-height: 1.4;
}

small {
    display: block;
    margin-top: 4px;
    color: #6b7280;
    font-size: 0.75rem;
}

.preview-section {
    flex: 1;
    padding: 32px 32px 16px 32px;
    background: #fafbfc;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.preview-section h2 {
    color: #1a202c;
    margin: 0 0 24px 0;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.flyer {
    width: 650px;
    height: 900px;
    background: white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    border: none;
    border-radius: 0;
    position: relative;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin-bottom: 8px;
}

.flyer-redfin {
    display: flex;
    flex-direction: column;
    padding: 0;
    height: 100%;
}

.flyer-main-image {
    width: 100%;
    height: 350px;
    overflow: hidden;
    position: relative;
    border-radius: 0;
}

.flyer-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.flyer-gallery {
    display: flex;
    height: 140px;
    gap: 0;
}

.flyer-gallery img {
    width: 33.333%;
    flex: 0 0 33.333%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.flyer-content {
    display: flex;
    flex: 1;
    padding: 25px;
}

.flyer-left {
    flex: 1;
    padding-right: 25px;
}

.flyer-right {
    flex: 1;
    padding-left: 25px;
}

.company-logo {
    color: #374151;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #d1d5db;
}

.right-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.right-header h3 {
    color: #4b5563;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.mls-number-right {
    font-size: 10px;
    color: #6b7280;
    font-weight: 600;
    background: #f9fafb;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.property-title {
    font-size: 24px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 8px;
    line-height: 1.2;
}

.property-address {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 20px;
}

.property-price {
    font-size: 32px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 20px;
}

.property-stats {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    display: block;
}

.stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

.property-description {
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 20px;
}

.highlights {
    margin-bottom: 20px;
}

.highlights h4 {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 10px;
    margin-top: 20px;
}

.highlights ul {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 20px;
}

.highlights li {
    font-size: 12px;
    color: #333;
    margin-bottom: 5px;
    position: relative;
    padding-left: 15px;
}

.highlights li:before {
    content: "•";
    color: #2c5aa0;
    position: absolute;
    left: 0;
}

.agent-section {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    margin-top: auto;
}

.agent-info-redfin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.agent-details {
    flex: 1;
}

.agent-name-redfin {
    font-size: 13px;
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
    line-height: 1.2;
}

.agent-title {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
    line-height: 1.2;
}

.agent-contact-redfin {
    font-size: 10px;
    color: #333;
    line-height: 1.2;
}

.agent-logo {
    max-height: 70px;
    max-width: 120px;
    object-fit: contain;
    object-position: center;
    width: auto;
    height: auto;
}

.flyer-modern {
    display: grid;
    grid-template-areas: 
        "header header"
        "main-image details"
        "gallery gallery"
        "footer footer";
    grid-template-rows: 1fr 3fr 2fr 1fr;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    padding: 30px;
}

.flyer-elegant {
    display: flex;
    flex-direction: column;
    padding: 40px;
}

.flyer-classic {
    display: grid;
    grid-template-areas: 
        "header header"
        "left right"
        "footer footer";
    grid-template-rows: 1fr 4fr 1fr;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

.flyer-header {
    grid-area: header;
    text-align: center;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
}

.just-listed {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 10px;
}

.price {
    font-size: 2.5em;
    font-weight: bold;
    margin: 10px 0;
}

.address {
    font-size: 1.3em;
    opacity: 0.9;
}

.main-image {
    grid-area: main-image;
    border-radius: 10px;
    overflow: hidden;
}

.main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.details {
    grid-area: details;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.details h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.detail-item {
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.detail-label {
    font-weight: bold;
    color: #2c3e50;
}

.gallery {
    grid-area: gallery;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.gallery img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
}

.flyer-footer {
    grid-area: footer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #2c3e50;
    color: white;
    border-radius: 10px;
}

.agent-info {
    display: flex;
    flex-direction: column;
}

.agent-name {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.agent-contact {
    font-size: 0.9em;
    opacity: 0.9;
}

.logo {
    max-height: 50px;
    max-width: 150px;
    object-fit: contain;
}

.description {
    font-size: 1.1em;
    line-height: 1.6;
    color: #2c3e50;
    margin: 20px 0;
}

@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        border-radius: 0;
    }
    
    .form-section {
        display: none;
    }
    
    .preview-section {
        padding: 0;
        background: white;
    }
    
    .flyer {
        box-shadow: none;
    }
}

#downloadBtn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#downloadBtn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#downloadBtn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.1);
}

.interactive-image {
    transition: all 0.3s ease;
    position: relative;
}

.interactive-image:hover {
    opacity: 0.8 !important;
    border: 2px dashed #3498db !important;
    box-sizing: border-box;
}

.interactive-image:hover::after {
    content: '📷 Click to upload';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
}

.flyer-main-image .interactive-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.image-placeholder {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 2px dashed #cbd5e0;
    color: #718096;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 8px;
}

.image-placeholder:hover {
    background: #edf2f7;
    border-color: #667eea;
    color: #667eea;
}

.main-placeholder {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.gallery-placeholder {
    width: 33.333%;
    flex: 0 0 33.333%;
    height: 100%;
}

.gallery-placeholder span {
    font-size: 1.5rem;
    font-weight: 300;
}

.main-placeholder span {
    font-size: 0.875rem;
}

.image-placeholder svg {
    opacity: 0.7;
}