/**
 * File: /assets/css/public.css
 * Base public styles for Custom Gains plugin
 * Includes general styles, utilities, and WordPress integration
 */

/* Base Plugin Styles */
.custom-gains-plugin {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333333;
}

/* WordPress Integration Styles */
.cg-builder-page-wrapper {
    margin: 0;
    padding: 0;
}

/* Remove WordPress theme interference */
.cg-builder-page-wrapper * {
    box-sizing: border-box;
}

.cg-builder-page-wrapper .entry-content,
.cg-builder-page-wrapper .post-content {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* Hide WordPress elements on builder pages */
.cg-builder-active .entry-title,
.cg-builder-active .post-navigation,
.cg-builder-active .entry-meta,
.cg-builder-active .entry-footer,
.cg-builder-active .post-edit-link {
    display: none;
}

/* Base Typography */
.custom-gains-plugin h1,
.custom-gains-plugin h2,
.custom-gains-plugin h3,
.custom-gains-plugin h4,
.custom-gains-plugin h5,
.custom-gains-plugin h6 {
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 16px;
}

.custom-gains-plugin p {
    margin: 0 0 16px;
    line-height: 1.6;
}

.custom-gains-plugin a {
    color: #0073aa;
    text-decoration: none;
    transition: color 0.2s ease;
}

.custom-gains-plugin a:hover {
    color: #005177;
}

/* Utility Classes */
.cg-hidden {
    display: none !important;
}

.cg-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.cg-clearfix::after {
    content: "";
    display: table;
    clear: both;
}

.cg-text-center { text-align: center; }
.cg-text-left { text-align: left; }
.cg-text-right { text-align: right; }

.cg-mt-0 { margin-top: 0; }
.cg-mt-1 { margin-top: 8px; }
.cg-mt-2 { margin-top: 16px; }
.cg-mt-3 { margin-top: 24px; }
.cg-mt-4 { margin-top: 32px; }

.cg-mb-0 { margin-bottom: 0; }
.cg-mb-1 { margin-bottom: 8px; }
.cg-mb-2 { margin-bottom: 16px; }
.cg-mb-3 { margin-bottom: 24px; }
.cg-mb-4 { margin-bottom: 32px; }

.cg-p-0 { padding: 0; }
.cg-p-1 { padding: 8px; }
.cg-p-2 { padding: 16px; }
.cg-p-3 { padding: 24px; }
.cg-p-4 { padding: 32px; }

/* Loading States */
.cg-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.cg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: cg-spin 1s linear infinite;
}

@keyframes cg-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form Elements */
.cg-form-group {
    margin-bottom: 20px;
}

.cg-form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333333;
}

.cg-form-control {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
    background-color: #ffffff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.cg-form-control:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.cg-form-control:disabled {
    background-color: #f8f9fa;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Button Styles */
.cg-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.cg-button:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.cg-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cg-button-primary {
    background-color: #0073aa;
    border-color: #0073aa;
    color: #ffffff;
}

.cg-button-primary:hover:not(:disabled) {
    background-color: #005177;
    border-color: #005177;
    color: #ffffff;
}

.cg-button-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #ffffff;
}

.cg-button-secondary:hover:not(:disabled) {
    background-color: #545b62;
    border-color: #545b62;
    color: #ffffff;
}

.cg-button-outline {
    background-color: transparent;
    border-color: #0073aa;
    color: #0073aa;
}

.cg-button-outline:hover:not(:disabled) {
    background-color: #0073aa;
    color: #ffffff;
}

.cg-button-success {
    background-color: #28a745;
    border-color: #28a745;
    color: #ffffff;
}

.cg-button-success:hover:not(:disabled) {
    background-color: #218838;
    border-color: #218838;
    color: #ffffff;
}

.cg-button-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #ffffff;
}

.cg-button-danger:hover:not(:disabled) {
    background-color: #c82333;
    border-color: #c82333;
    color: #ffffff;
}

.cg-button-small {
    padding: 8px 16px;
    font-size: 12px;
}

.cg-button-large {
    padding: 16px 32px;
    font-size: 16px;
}

/* Card Styles */
.cg-card {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.cg-card-header {
    padding: 16px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.cg-card-body {
    padding: 20px;
}

.cg-card-footer {
    padding: 16px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.cg-card-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px;
}

.cg-card-subtitle {
    font-size: 14px;
    color: #6c757d;
    margin: 0 0 16px;
}

/* Alert Styles */
.cg-alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
}

.cg-alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.cg-alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.cg-alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.cg-alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.cg-alert-dismissible {
    padding-right: 48px;
    position: relative;
}

.cg-alert-close {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
}

.cg-alert-close:hover {
    opacity: 1;
}

/* Badge Styles */
.cg-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cg-badge-primary {
    color: #ffffff;
    background-color: #0073aa;
}

.cg-badge-secondary {
    color: #ffffff;
    background-color: #6c757d;
}

.cg-badge-success {
    color: #ffffff;
    background-color: #28a745;
}

.cg-badge-danger {
    color: #ffffff;
    background-color: #dc3545;
}

.cg-badge-warning {
    color: #212529;
    background-color: #ffc107;
}

.cg-badge-info {
    color: #ffffff;
    background-color: #17a2b8;
}

/* Progress Bar Styles */
.cg-progress {
    display: flex;
    height: 8px;
    overflow: hidden;
    background-color: #e9ecef;
    border-radius: 4px;
}

.cg-progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #ffffff;
    text-align: center;
    white-space: nowrap;
    background-color: #0073aa;
    transition: width 0.6s ease;
}

.cg-progress-bar-striped {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
    background-size: 16px 16px;
}

.cg-progress-bar-animated {
    animation: cg-progress-bar-stripes 1s linear infinite;
}

@keyframes cg-progress-bar-stripes {
    0% {
        background-position: 16px 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* Table Styles */
.cg-table {
    width: 100%;
    margin-bottom: 16px;
    background-color: transparent;
    border-collapse: collapse;
}

.cg-table th,
.cg-table td {
    padding: 12px;
    vertical-align: top;
    border-top: 1px solid #dee2e6;
    text-align: left;
}

.cg-table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.cg-table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

.cg-table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Responsive Utilities */
.cg-d-none { display: none !important; }
.cg-d-block { display: block !important; }
.cg-d-inline { display: inline !important; }
.cg-d-inline-block { display: inline-block !important; }
.cg-d-flex { display: flex !important; }

/* Responsive Display Utilities */
@media (max-width: 575px) {
    .cg-d-sm-none { display: none !important; }
    .cg-d-sm-block { display: block !important; }
    .cg-d-sm-flex { display: flex !important; }
}

@media (max-width: 767px) {
    .cg-d-md-none { display: none !important; }
    .cg-d-md-block { display: block !important; }
    .cg-d-md-flex { display: flex !important; }
}

@media (max-width: 991px) {
    .cg-d-lg-none { display: none !important; }
    .cg-d-lg-block { display: block !important; }
    .cg-d-lg-flex { display: flex !important; }
}

/* Error and Debug Styles */
.cg-error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 16px;
    margin: 16px 0;
}

.cg-debug {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 16px;
    margin: 16px 0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* WordPress Admin Bar Compatibility */
body.admin-bar .cg-builder-header {
    padding-top: calc(40px + 20px);
}

@media screen and (max-width: 782px) {
    body.admin-bar .cg-builder-header {
        padding-top: calc(46px + 20px);
    }
}

/* RTL Support */
[dir="rtl"] .cg-alert-dismissible {
    padding-right: 16px;
    padding-left: 48px;
}

[dir="rtl"] .cg-alert-close {
    right: auto;
    left: 16px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .cg-card {
        border-width: 2px;
    }
    
    .cg-button {
        border-width: 2px;
    }
    
    .cg-form-control {
        border-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .cg-button,
    .cg-form-control,
    .cg-progress-bar {
        transition: none;
    }
    
    .cg-loading::after,
    .cg-progress-bar-animated {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .cg-button,
    .cg-alert-dismissible .cg-alert-close {
        display: none;
    }
    
    .cg-card {
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .cg-alert {
        border: 1px solid #000;
    }
}