/**
 * Spiritual Gifts Assessment Frontend Admin Styles
 */

/* Main Container */
.sg-admin-frontend {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Content Wrapper */
.sg-admin-content {
    margin-top: 20px;
    background: #f0f0f1;
    border-radius: 4px;
    padding: 20px;
}

/* Dashboard Overview */
.sg-dashboard-container {
    margin: 20px 0;
}

.sg-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sg-dashboard-header h1 {
    margin: 0;
    font-size: 23px;
    font-weight: 400;
    padding: 9px 0 4px 0;
    line-height: 1.3;
}

/* Navigation */
.sg-admin-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #c3c4c7;
    padding-bottom: 10px;
}

.sg-nav-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    text-decoration: none;
    color: #50575e;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sg-nav-item:hover {
    background: #f0f0f1;
    color: #1d2327;
}

.sg-nav-item.active {
    background: #2271b1;
    color: #fff;
}

.sg-nav-item .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Stats Cards */
.sg-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sg-stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-stat-title {
    color: #50575e;
    font-size: 14px;
    margin: 0 0 10px;
}

.sg-stat-value {
    font-size: 24px;
    font-weight: 600;
    color: #2271b1;
    margin: 0;
}

/* Charts Section */
.sg-charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sg-chart-card {
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    height: 400px;
    position: relative;
}

.sg-chart-card canvas {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: calc(100% - 60px) !important;
}

.sg-chart-title {
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 16px;
    color: #1d2327;
}

/* Tables */
.sg-table-container {
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow-x: auto;
}

.sg-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.sg-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sg-header-actions .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

.sg-table-header h1 {
    margin: 0;
    font-size: 23px;
    font-weight: 400;
    padding: 9px 0 4px 0;
    line-height: 1.3;
}

.sg-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    min-width: 800px;
}

.sg-table th,
.sg-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #c3c4c7;
    vertical-align: middle;
}

.sg-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1d2327;
    position: sticky;
    top: 0;
    z-index: 1;
}

.sg-table tr:hover {
    background: #f6f7f7;
}

.sg-table td:last-child {
    white-space: nowrap;
}

/* Button Group */
.sg-button-group {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
}

.sg-button-group .sg-button {
    flex: 0 0 auto;
}

/* Filters */
.sg-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.sg-filter {
    display: flex;
    flex-direction: column;
}

.sg-filter label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #1d2327;
}

.sg-filter select {
    min-width: 150px;
}

.sg-date-range {
    min-width: 260px;
}

/* Responsive Filters */
@media screen and (max-width: 782px) {
    .sg-filters {
        flex-direction: column;
        overflow-x: visible;
    }

    .sg-filter select,
    .sg-date-range {
        width: 100%;
    }
}

/* Bulk Actions */
.sg-bulk-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.sg-bulk-actions select {
    min-width: 150px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    height: 36px;
}

.sg-bulk-actions .sg-button {
    height: 36px;
    padding: 0 16px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Responsive Bulk Actions */
@media screen and (max-width: 782px) {
    .sg-bulk-actions {
        flex-direction: column;
        overflow-x: visible;
    }

    .sg-bulk-actions select,
    .sg-bulk-actions .sg-button {
        width: 100%;
    }
}

/* Buttons */
.sg-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 13px;
    line-height: 2;
    min-height: 30px;
}

.sg-button:hover {
    background: #135e96;
    color: #fff;
    text-decoration: none;
}

.sg-button.secondary {
    background: #f6f7f7;
    color: #2c3338;
    border: 1px solid #c3c4c7;
}

.sg-button.secondary:hover {
    background: #f0f0f1;
    border-color: #8c8f94;
}

/* Settings Page */
.sg-settings-container {
    background: #f0f0f1;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

.sg-settings-section {
    background: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-settings-section h2 {
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dcdcde;
    font-size: 16px;
    color: #1d2327;
}

/* Forms */
.sg-form-group {
    margin-bottom: 20px;
}

.sg-form-group:last-child {
    margin-bottom: 0;
}

.sg-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #1d2327;
}

.sg-form-group .description {
    margin-top: 5px;
    color: #646970;
    font-style: italic;
    font-size: 13px;
}

.sg-form-group input[type="text"],
.sg-form-group input[type="number"],
.sg-form-group textarea,
.sg-form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
}

.sg-form-group input[type="number"] {
    max-width: 100px;
}

/* Checkbox Styling */
.sg-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    margin-bottom: 0;
}

.sg-checkbox input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
}

/* Form Actions */
.sg-form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #dcdcde;
    text-align: right;
}

/* Success Notice */
.sg-notice {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.sg-notice-success {
    background: #d1e7dd;
    color: #0a3622;
    border: 1px solid #a3cfbb;
}

.sg-notice-warning {
    background: #fff3cd;
    color: #664d03;
    border: 1px solid #ffecb5;
}

/* Result Details */
.sg-result-meta {
    background: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: start;
}

.sg-meta-item {
    border-left: 3px solid #2271b1;
    padding-left: 10px;
    min-width: 200px;
    max-width: 300px;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.sg-meta-label {
    color: #646970;
    font-size: 12px;
    margin: 0;
}

.sg-meta-value {
    margin: 5px 0 0;
    font-weight: 600;
    color: #1d2327;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.sg-meta-value .description {
    display: block;
    font-size: 14px;
    color: #646970;
    font-weight: normal;
    margin-top: 4px;
}

/* Section Header */
.sg-section-header {
    margin: 30px 0 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dcdcde;
}

.sg-section-header h2 {
    margin: 0;
    font-size: 18px;
    color: #1d2327;
    font-weight: 600;
}

/* Gift Scores */
.sg-scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sg-score-item {
    padding: 20px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sg-score-header strong {
    font-size: 16px;
    color: #1d2327;
}

.sg-score-header span {
    font-weight: 600;
    color: #2271b1;
}

.sg-score-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.sg-score-fill {
    height: 100%;
    background: #2271b1;
    transition: width 0.3s ease;
}

.sg-gift-scripture {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #dcdcde;
    color: #646970;
    font-style: italic;
}

/* Question Responses */
.sg-responses {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
}

.sg-response {
    background: #fff;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sg-response-header {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.sg-question-number {
    flex: 0 0 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    background: #2271b1;
    color: #fff;
    border-radius: 50%;
}

.sg-question-text {
    flex: 1;
}

.sg-answer-grid {
    display: flex;
    gap: 10px;
}

.sg-answer {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.sg-answer.selected {
    background: #e8f0fe;
    border-color: #2271b1;
    color: #2271b1;
}

/* Dream Team Recommendations */
.sg-recommendations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.sg-recommendation {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.sg-recommendation .dashicons {
    color: #2271b1;
}

/* Status Badges */
.sg-status,
.sg-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.sg-status-completed,
.sg-status-success {
    background: #d1e7dd;
    color: #0a3622;
}

.sg-status-incomplete,
.sg-status-failed {
    background: #f8d7da;
    color: #58151c;
}

.sg-badge {
    background: #e9ecef;
    color: #495057;
}

/* Table Columns */
.sg-table td.column-user {
    min-width: 200px;
    max-width: 250px;
}

.sg-table td.column-user .description {
    display: block;
    font-size: 12px;
    color: #646970;
    word-break: break-word;
}

/* Email Log Table */
.sg-table td.column-note {
    max-width: 300px;
    white-space: normal;
    word-break: break-word;
}

.sg-table td.column-recipient {
    min-width: 200px;
}

.sg-table td.column-type,
.sg-table td.column-status {
    width: 120px;
    text-align: center;
}

.sg-table td.column-sent {
    width: 160px;
    white-space: nowrap;
}

.sg-table td.column-actions {
    width: 120px;
    text-align: right;
}

/* Back to Top Button */
.sg-back-to-top {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
}

.sg-back-to-top .sg-button {
    padding: 8px 16px;
}

.sg-back-to-top .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

/* Modal */
#sg-email-note {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    resize: vertical;
    margin: 10px 0;
}

.sg-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 100000;
    display: none;
}

.sg-modal-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    margin: 100px auto;
    padding: 20px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sg-modal-close {
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
    font-size: 20px;
    color: #646970;
}

.sg-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #dcdcde;
}

/* Pagination */
.sg-pagination {
    display: flex;
    gap: 5px;
    margin-top: 20px;
    justify-content: center;
}

.sg-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 4px;
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    color: #2271b1;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 13px;
}

.sg-page-number:hover {
    background: #f0f0f1;
    border-color: #8c8f94;
    color: #135e96;
}

.sg-page-number.current {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    cursor: default;
}

/* Users Table */
.sg-users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.sg-users-table th,
.sg-users-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #c3c4c7;
    vertical-align: middle;
}

.sg-users-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1d2327;
}

.sg-users-table tr:hover {
    background: #f6f7f7;
}

.sg-users-table td:last-child {
    text-align: center;
    width: 100px;
}

/* Print Styles */
@media print {
    /* Hide WordPress admin UI and website footer */
    #adminmenumain,
    #wpadminbar,
    #wpfooter,
    .sg-actions,
    .page-title-action,
    .sg-back-to-top,
    .sg-header-actions,
    #colophon,
    .site-footer,
    footer {
        display: none !important;
    }

    /* Reset margins and padding */
    .sg-admin-content {
        margin: 0 !important;
        padding: 0 !important;
        background: none !important;
    }

    /* Remove box shadows and borders */
    .sg-table-container,
    .sg-result-meta,
    .sg-score-item {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        background: white !important;
        margin-bottom: 0 !important;
    }

    /* Ensure all content is visible with proper spacing */
    .sg-scores-grid {
        display: block !important;
        page-break-inside: avoid !important;
        margin-bottom: 15px !important;
    }

    .sg-recommendations {
        display: block !important;
        page-break-inside: avoid !important;
        margin-top: 10px !important;
    }

    /* Adjust section spacing */
    .sg-section-header {
        margin: 10px 0 5px !important;
        padding-bottom: 5px !important;
        border-bottom: 1px solid #ddd !important;
    }

    .sg-section-header h2 {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Compact meta section */
    .sg-result-meta {
        margin-bottom: 10px !important;
        padding: 10px !important;
    }

    /* Remove extra space between sections */
    .sg-scores-grid {
        margin-top: 0 !important;
    }

    .sg-recommendations {
        margin-top: 0 !important;
    }

    .sg-table-container > div:not(:first-child) {
        margin-top: 10px !important;
    }

    /* Ensure text is readable */
    body {
        background: white !important;
        color: black !important;
    }

    /* Force background colors to print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Adjust meta grid for print */
    .sg-meta-grid {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sg-meta-item {
        display: inline-block !important;
        margin: 0 20px 10px 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    .sg-meta-label,
    .sg-meta-value {
        display: inline !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sg-meta-label:after {
        content: ": ";
    }
}

/* Responsive Adjustments */
@media screen and (max-width: 782px) {
    .sg-dashboard-header,
    .sg-table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .sg-admin-nav {
        flex-direction: column;
    }

    .sg-filters,
    .sg-bulk-actions {
        flex-direction: column;
    }

    .sg-filter,
    .sg-bulk-actions select,
    .sg-bulk-actions button {
        width: 100%;
    }

    .sg-table {
        display: block;
        overflow-x: auto;
    }

    .sg-meta-grid,
    .sg-scores-grid,
    .sg-charts-container {
        grid-template-columns: 1fr;
    }

    .sg-button {
        width: 100%;
        justify-content: center;
    }
}
