/**
 * AI Content Studio - Admin Styles
 * Version: 1.0.0
 * 
 * Table of Contents:
 * 1. Global & Animations
 * 2. Dashboard Page
 * 3. Generator Page (Content & Image)
 * 4. History Page
 * 5. Responsive Styles
 */

/* ========================================
   1. GLOBAL & ANIMATIONS
   ======================================== */

/* Keyframe Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

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

/* Button States & Styles */
.button .spinner {
    float: none;
    margin: 0 5px 0 0;
    vertical-align: middle;
}

.button.button-primary.success,
.button.button-success {
    background: #00a32a !important;
    border-color: #00a32a !important;
    color: white !important;
}

.button.button-success:hover {
    background: #008a20 !important;
    border-color: #008a20 !important;
}

/* Notification Styles */
.ai-studio-notification a {
    color: white !important;
    text-decoration: underline !important;
    font-weight: 600;
}

.ai-studio-notification a:hover {
    opacity: 0.8;
}

/* ========================================
   2. DASHBOARD PAGE
   ======================================== */

.ai-studio-dashboard h2 {
    font-size: 18px;
    font-weight: 600;
}

/* ========================================
   3. GENERATOR PAGE (Content & Image)
   ======================================== */

/* WordPress Admin Compatibility */
.wrap.ngm-content-ai-generator {
    margin-right: 20px;
    max-width: 100%;
    overflow-x: hidden;
}

.ngm-content-ai-generator {
    max-width: 100%;
    overflow: hidden;
}

/* Tab Navigation */
.nav-tab-wrapper {
    margin: 20px 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Generator Layout Container */
.ai-studio-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    margin-top: 20px;
    max-width: 100%;
    box-sizing: border-box;
}

.ai-studio-input-panel,
.ai-studio-output-panel {
    min-width: 0; 
    max-width: 100%;
    box-sizing: border-box;
}

.ai-studio-card {
    background: #fff;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    padding: 20px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

.ai-studio-card h2 {
    margin-top: 0;
}

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

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

.form-group .required {
    color: #dc3232;
}

.form-group .description {
    margin-top: 5px;
}

/* States: Empty, Loading, Error */
.ai-studio-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.ai-studio-state .dashicons {
    display: block;
    margin: 0 auto 25px;
}

.ai-studio-spinner {
    margin-bottom: 20px;
}

.ai-studio-error {
    background: #fcf0f1;
    border-left: 4px solid #dc3232;
    padding: 20px;
}

.spinner{
    float: none;
}

/* Output Display */
.ai-studio-output {
    animation: fadeIn 0.3s ease-in;
}

.output-title-section,
.output-content-section {
    margin-bottom: 20px;
    max-width: 100%;
}

.output-title-section label,
.output-content-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.output-title-section input {
    max-width: 100%;
    box-sizing: border-box;
}

/* Generated Content Preview */
.generated-content-preview {
    background: #f9f9f9;
    border: 1px solid #ddd;
    padding: 20px;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden; /* CRITICAL: Prevents horizontal overflow */
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

.generated-content-preview h2,
.generated-content-preview h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    word-wrap: break-word;
}

.generated-content-preview p {
    margin-bottom: 1em;
    word-wrap: break-word;
}

.generated-content-preview img {
    max-width: 100%;
    height: auto;
}

/* Output Meta & Actions */
.output-meta {
    display: flex;
    gap: 30px;
    padding: 15px;
    background: #f0f6fc;
    border-radius: 4px;
    margin-bottom: 20px;
}

.output-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.output-actions .button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.output-actions .button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.output-actions .button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Rate Limit Info */
.rate-limit-info {
    margin-top: 10px !important;
    color: #666;
}

/* Image Generator Specific */
.image-preview-section {
    margin-bottom: 20px;
}

.image-preview-section img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ========================================
   4. HISTORY PAGE
   ======================================== */

/* Stats Grid */
.acs-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.acs-stat-box {
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.acs-stat-primary { border-left: 4px solid #2271b1; }
.acs-stat-success { border-left: 4px solid #00a32a; }
.acs-stat-warning { border-left: 4px solid #f0b849; }
.acs-stat-danger { border-left: 4px solid #dc3232; }

.acs-stat-value {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 5px;
}

.acs-stat-label {
    color: #666;
    font-size: 13px;
}

/* Filters Container */
.acs-filters-container {
    background: #fff;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.acs-filters-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.acs-filter-field {
    display: flex;
    flex-direction: column;
}

.acs-filter-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
}

.acs-filter-field select,
.acs-filter-field input[type="search"] {
    height: 32px;
    padding: 0 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 13px;
}

.acs-filter-field select {
    min-width: 150px;
}

.acs-filter-search {
    flex: 1;
    min-width: 200px;
}

.acs-filter-search input[type="search"] {
    width: 100%;
}

.acs-filter-actions {
    display: flex;
    gap: 5px;
}

/* Empty State */
.acs-empty-state {
    background: #fff;
    padding: 40px;
    text-align: center;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.acs-empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.acs-empty-message {
    color: #666;
    margin-top: 10px;
    font-size: 14px;
}

.acs-empty-state p {
    margin: 10px 0;
}

.acs-empty-state .button-primary {
    margin-top: 10px;
}

/* History Table */
.acs-history-table .acs-col-type { width: 40px; text-align: center; }
.acs-history-table .acs-col-provider { width: 120px; }
.acs-history-table .acs-col-words { width: 100px; }
.acs-history-table .acs-col-cost { width: 80px; }
.acs-history-table .acs-col-time { width: 80px; }
.acs-history-table .acs-col-date { width: 150px; }

.acs-tone {
    color: #666;
}

.acs-provider-badge {
    display: inline-block;
    padding: 3px 8px;
    background: #f0f6fc;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

.acs-cost-paid {
    color: #dc3232;
    font-weight: 500;
}

.acs-cost-free {
    color: #00a32a;
    font-weight: 500;
}

/* ========================================
   5. RESPONSIVE STYLES
   ======================================== */

/* Large Screens: Adjust Generator Layout */
@media (max-width: 1600px) {
    .ai-studio-container {
        grid-template-columns: 1fr 1fr; /* Equal columns */
    }
}

/* Medium Screens: Stack Generator */
@media (max-width: 1280px) {
    .ai-studio-container {
        grid-template-columns: 1fr;
    }
}

/* Tablets */
@media (max-width: 782px) {
    /* Generator */
    .ai-studio-card {
        padding: 15px;
    }
    
    .output-meta {
        flex-direction: column;
        gap: 10px;
    }
    
    .output-actions {
        flex-direction: column;
    }
    
    .output-actions .button {
        width: 100%;
        justify-content: center;
    }
    
    /* History: Stats Grid - 2 columns */
    .acs-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* History: Filters Stack */
    .acs-filters-form {
        flex-wrap: wrap;
    }
    
    .acs-filter-field {
        flex: 1 1 calc(50% - 5px);
        min-width: 140px;
    }
    
    .acs-filter-search {
        flex: 1 1 100%;
    }
    
    .acs-filter-actions {
        flex: 1 1 100%;
        justify-content: flex-start;
    }
    
    /* History: Hide less important columns */
    .acs-history-table .acs-col-words,
    .acs-history-table .acs-col-time {
        display: none;
    }
    
    /* Dashboard */
    .ai-studio-stats-grid,
    .ai-studio-quick-actions > div {
        grid-template-columns: 1fr !important;
    }
    
    .ai-studio-dashboard > div[style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Small Tablets */
@media (max-width: 600px) {
    /* History: Stats Grid - 1 column */
    .acs-stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* History: Full width filters */
    .acs-filter-field {
        flex: 1 1 100%;
    }
    
    /* History: Hide more columns */
    .acs-history-table .acs-col-provider,
    .acs-history-table .acs-col-cost {
        display: none;
    }
}

/* Mobile */
@media (max-width: 480px) {
    /* Reduce padding */
    .acs-stat-box,
    .acs-filters-container,
    .acs-empty-state {
        padding: 12px;
    }
    
    .acs-stat-value {
        font-size: 20px;
    }
}

/* ========================================
   SETTINGS PAGE
   ======================================== */

/* Quick Start Card */
.acs-quick-start-card {
    background: #fff;
    border: 1px solid #ddd;
    border-left: 4px solid #2271b1;
    padding: 20px;
    border-radius: 6px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.acs-quick-start-card h3 {
    margin-top: 0;
    color: #1e293b;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.acs-quick-start-card ol {
    margin: 10px 0 0 0;
    padding-left: 20px;
    line-height: 1.8;
}

.acs-quick-start-card a {
    color: #2271b1;
    text-decoration: none;
}

.acs-quick-start-card a:hover {
    text-decoration: underline;
}

/* Features Cards Grid */
.acs-features-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.acs-feature-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.acs-feature-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.acs-feature-card h4 {
    margin: 0 0 15px 0;
    font-size: 15px;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.acs-feature-card ul {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: #666;
    line-height: 1.8;
}

.acs-feature-card ul li {
    margin-bottom: 6px;
}

.acs-feature-card strong {
    color: #1e293b;
}

/* Icon Badges */
.acs-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #f0f0f0;
    border-radius: 4px;
}
.acs-icon-badge .dashicons {
    font-size: 12px;
    line-height: 1.5;
}

/* Settings Form Container */
.acs-settings-form-container {
    background: #fff;
    padding: 25px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.acs-settings-form-container h2 {
    margin-top: 0;
    font-size: 18px;
    color: #1e293b;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

/* Responsive */
@media (max-width: 1280px) {
    .acs-features-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 782px) {
    .acs-quick-start-card,
    .acs-feature-card,
    .acs-settings-form-container {
        padding: 15px;
    }
}

/* ========================================
   DASHBOARD PAGE
   ======================================== */

/* Stats Grid */
.acs-dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 30px 0;
}

.acs-stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.acs-stat-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.acs-stat-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.acs-stat-info p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.acs-stat-info h2 {
    margin: 10px 0 0 0;
    font-size: 32px;
    font-weight: 600;
    color: #1e293b;
}

.acs-stat-info .acs-stat-period {
    margin: 5px 0 0 0;
    color: #999;
    font-size: 12px;
}

.acs-stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.acs-stat-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Icon Color Variants */
.acs-icon-blue {
    background: #e3f2fd;
}

.acs-icon-blue .dashicons {
    color: #1976d2;
}

.acs-icon-green {
    background: #e8f5e9;
}

.acs-icon-green .dashicons {
    color: #2e7d32;
}

.acs-icon-orange {
    background: #fff3e0;
}

.acs-icon-orange .dashicons {
    color: #ef6c00;
}

.acs-icon-purple {
    background: #f3e5f5;
}

.acs-icon-purple .dashicons {
    color: #7b1fa2;
}

/* Quick Actions */
.acs-quick-actions {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.acs-quick-actions h2 {
    margin-top: 0;
    font-size: 18px;
}

.acs-actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.acs-action-btn {
    height: auto;
    padding: 20px;
    text-align: center;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.acs-action-btn .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Dashboard Grid */
.acs-dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* Recent Activity */
.acs-recent-activity {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.acs-recent-activity h2 {
    margin-top: 0;
    font-size: 18px;
}

.acs-empty-activity {
    color: #666;
    text-align: center;
    padding: 40px 0;
}

/* System Status */
.acs-system-status {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.acs-system-status h2 {
    margin-top: 0;
    font-size: 18px;
}

.acs-system-status h3 {
    font-size: 15px;
    margin-top: 20px;
}

.acs-status-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f0f6fc;
    border-radius: 4px;
    margin-bottom: 10px;
}

.acs-status-connected {
    color: #00a32a;
}

.acs-status-disconnected {
    color: #dc3232;
}

.acs-tips-list {
    margin: 10px 0 0 0;
    padding-left: 20px;
    color: #666;
    font-size: 13px;
    line-height: 1.8;
}

/* Dashboard Responsive */
@media (max-width: 1280px) {
    .acs-dashboard-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .acs-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .acs-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 782px) {
    .acs-dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .acs-actions-grid {
        grid-template-columns: 1fr;
    }
    
    .acs-stat-card,
    .acs-quick-actions,
    .acs-recent-activity,
    .acs-system-status {
        padding: 15px;
    }
    
    .acs-stat-info h2 {
        font-size: 24px;
    }
}

/* Generate Buttons */
#generate-btn, #generate-image-btn {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Dashborad Buttons*/
.wp-core-ui .button-primary.acs-action-btn, .wp-core-ui .button-secondary.acs-action-btn {
    display: flex;
    flex-direction: row;
}

