/* ========================================
   Document Maker - Frontend Styles
   ======================================== */

/* Global fixes for header overlap */
body.document-maker-page,
body.page-template-document-maker,
body.single-dm_template {
    padding-top: 80px !important; /* Add top padding to body */
}

/* Specific fixes for document maker pages */
.document-maker-page .dm-template-gallery,
.document-maker-page .dm-premium-hero,
.document-maker-page .dm-gallery-container {
    margin-top: 100px !important;
    padding-top: 20px;
}

/* Fix for overlapping with website header */
.dm-template-gallery,
.dm-gallery-container,
.dm-premium-hero,
.dm-templates-grid {
    position: relative !important;
    z-index: 1 !important;
    margin-top: 20px !important;
}

/* Common WordPress theme header fixes */
.wp-header-fixed .dm-template-gallery,
.wp-header-fixed .dm-premium-hero,
.wp-header-fixed .dm-gallery-container,
.fixed-header .dm-template-gallery,
.fixed-header .dm-premium-hero,
.fixed-header .dm-gallery-container,
.sticky-header .dm-template-gallery,
.sticky-header .dm-premium-hero,
.sticky-header .dm-gallery-container {
    margin-top: 120px !important;
    padding-top: 20px;
}

/* Ensure document maker content doesn't overlap with fixed headers */
.dm-template-gallery {
    display: grid;
    grid-template-columns: repeat(var(--columns, 3), 1fr);
    gap: 30px;
    margin: 60px 0 40px 0; /* Increased top margin */
    padding-top: 20px;
    position: relative;
    z-index: 1;
}

/* Template Gallery */
.dm-template-gallery {
    display: grid;
    grid-template-columns: repeat(var(--columns, 3), 1fr);
    gap: 30px;
    margin: 60px 0 40px 0; /* Increased top margin */
    padding-top: 20px;
    position: relative;
    z-index: 1;
}

.dm-template-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 1;
}

.dm-template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.dm-template-preview {
    height: 200px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e9ecef;
}

.dm-template-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.dm-template-placeholder {
    text-align: center;
    color: #6c757d;
}

.dm-placeholder-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.dm-placeholder-text {
    font-size: 14px;
    font-weight: 500;
}

.dm-template-info {
    padding: 20px;
}

.dm-template-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.dm-template-excerpt {
    margin: 0 0 20px 0;
    font-size: 14px;
    color: #6c757d;
    line-height: 1.5;
}

.dm-template-actions {
    display: flex;
    gap: 10px;
}

/* Template Display */
.dm-template-display {
    margin: 60px auto 40px auto; /* Increased top margin */
    padding-top: 20px;
    position: relative;
    z-index: 1;
}

.dm-template-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
}

.dm-template-content h1 {
    font-size: 32px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.dm-template-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: #34495e;
    margin: 30px 0 15px 0;
}

.dm-template-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: #34495e;
    margin: 25px 0 10px 0;
}

.dm-template-content p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 15px;
    color: #2c3e50;
}

.dm-template-content ul, .dm-template-content ol {
    margin: 15px 0;
    padding-left: 20px;
}

.dm-template-content li {
    margin-bottom: 8px;
    color: #2c3e50;
}

.dm-template-content .dm-section {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.dm-template-content .dm-heading-element {
    color: #2c3e50;
    font-size: 24px;
    font-weight: bold;
    margin: 20px 0 10px 0;
}

.dm-template-content .dm-paragraph-element {
    color: #2c3e50;
    font-size: 16px;
    line-height: 1.6;
    margin: 10px 0;
}

.dm-template-content .dm-text-element {
    color: #2c3e50;
    font-size: 16px;
}

.dm-template-content .dm-divider-element {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    margin: 30px 0;
}

.dm-template-content .dm-container-element {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    background: #f8f9fa;
}

.dm-template-content .dm-list-element {
    margin: 15px 0;
    padding-left: 20px;
}

/* Frontend Editor */
.dm-frontend-editor {
    max-width: 1200px;
    margin: 60px auto 0 auto; /* Increased top margin */
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
    z-index: 1;
    padding-top: 20px;
}

.dm-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.dm-editor-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.dm-editor-actions {
    display: flex;
    gap: 10px;
}

.dm-editor-content {
    padding: 0;
    min-height: 500px;
}

/* My Documents */
.dm-my-documents {
    margin: 60px 0 40px 0; /* Increased top margin */
    padding-top: 20px;
    position: relative;
    z-index: 1;
}

.dm-my-documents h2 {
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
}

.dm-documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.dm-document-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s ease;
}

.dm-document-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dm-document-info h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.dm-document-info p {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
}

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

/* Buttons */
.dm-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
    color: #495057;
    min-height: 40px;
    justify-content: center;
}

.dm-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dm-btn-primary {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.dm-btn-primary:hover {
    background: #5a6fd8;
    border-color: #5a6fd8;
}

.dm-btn-secondary {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.dm-btn-secondary:hover {
    background: #5a6268;
    border-color: #5a6268;
}

.dm-btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.dm-btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
}

/* Messages */
.dm-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.dm-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.dm-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.dm-no-templates,
.dm-no-documents,
.dm-login-required {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
}

.dm-login-required a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.dm-login-required a:hover {
    text-decoration: underline;
}

/* Additional fixes for header overlap */
.dm-premium-hero {
    margin-top: 0 !important;
    padding-top: 100px !important; /* Add top padding to account for fixed header */
    position: relative;
    z-index: 1;
}

.dm-gallery-container {
    margin-top: 40px !important;
    padding-top: 20px;
    position: relative;
    z-index: 1;
}

.dm-templates-grid {
    margin-top: 40px !important;
    position: relative;
    z-index: 1;
}

/* Ensure proper spacing from WordPress admin bar if present */
.admin-bar .dm-template-gallery,
.admin-bar .dm-premium-hero,
.admin-bar .dm-gallery-container {
    margin-top: 32px !important; /* WordPress admin bar height */
}

/* Responsive Design */
@media (max-width: 768px) {
    .dm-template-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
        margin-top: 40px !important;
    }
    
    .dm-template-actions {
        flex-direction: column;
    }
    
    .dm-editor-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .dm-editor-actions {
        width: 100%;
        justify-content: center;
    }
    
    .dm-document-card {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .dm-document-actions {
        width: 100%;
        justify-content: center;
    }
    
    .dm-premium-hero {
        padding-top: 80px !important;
    }
}

@media (max-width: 480px) {
    .dm-template-gallery {
        grid-template-columns: 1fr;
        margin-top: 30px !important;
    }
    
    .dm-documents-grid {
        grid-template-columns: 1fr;
    }
    
    .dm-premium-hero {
        padding-top: 60px !important;
    }
}

/* Print Styles */
@media print {
    .dm-template-actions,
    .dm-editor-header,
    .dm-editor-actions {
        display: none !important;
    }
    
    .dm-template-display {
        margin: 0;
        max-width: none;
    }
    
    .dm-template-content {
        box-shadow: none;
        border: none;
        padding: 0;
    }
}
