/**
 * Dezefy CRUD Plugin Styles
 * 
 * Complete styling for tables, modals, forms, and notifications
 * 
 * @package DezefyCRUD
 * @since 1.0.0
 */

/* ==========================================================================
   Variables and Root Styles
   ========================================================================== */

   :root {
    --dzcrud-primary: #0073aa;
    --dzcrud-primary-hover: #005a87;
    --dzcrud-success: #46b450;
    --dzcrud-warning: #ffb900;
    --dzcrud-danger: #dc3232;
    --dzcrud-info: #00a0d2;
    --dzcrud-border: #ddd;
    --dzcrud-bg-light: #f5f5f5;
    --dzcrud-text: #333;
    --dzcrud-text-muted: #666;
    --dzcrud-modal-overlay: rgba(0, 0, 0, 0.6);
    --dzcrud-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --dzcrud-radius: 3px;
    --dzcrud-transition: all 0.3s ease;
}

/* ==========================================================================
   General Styles
   ========================================================================== */

.dzcrud-wrapper {
    margin: 20px 0;
    position: relative;
}

.dzcrud-wrapper * {
    box-sizing: border-box;
}

/* ==========================================================================
   Toolbar Styles
   ========================================================================== */

.dzcrud-toolbar {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.dzcrud-export-wrapper {
    text-align: right;
}

.dzcrud-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--dzcrud-primary);
    color: white;
    border: none;
    border-radius: var(--dzcrud-radius);
    cursor: pointer;
    font-size: 14px;
    transition: var(--dzcrud-transition);
}

.dzcrud-export-btn:hover {
    background: var(--dzcrud-primary-hover);
}

.dzcrud-export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dzcrud-export-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   Table Container Styles
   ========================================================================== */

.dzcrud-table-container {
    background: white;
    border: 1px solid var(--dzcrud-border);
    border-radius: var(--dzcrud-radius);
    overflow: hidden;
    box-shadow: var(--dzcrud-shadow);
}

/* ==========================================================================
   DataTables Customization
   ========================================================================== */

.dzcrud-table {
    width: 100% !important;
    border-collapse: collapse;
}

.dzcrud-table thead th {
    background: var(--dzcrud-bg-light);
    border-bottom: 2px solid var(--dzcrud-border);
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--dzcrud-text);
    white-space: nowrap;
}

table.dataTable.dzcrud-table{
    border: 0px;
}

table.dataTable.dzcrud-table th{
    border: 0px;
    border-right: 0px;
    border-bottom: 1px solid var(--dzcrud-border);
    border-top: 1px solid var(--dzcrud-border);
}

.dzcrud-actions {
    padding-top: 10px;
    padding-bottom: 10px;
}

.dzcrud-table tbody td {
    padding: 10px;
    border-bottom: 0px solid var(--dzcrud-border);
    color: var(--dzcrud-text);
    border-right: 0px;
}

.dzcrud-table tbody tr:hover {
    background: #f9f9f9;
}

.dzcrud-table tbody tr:last-child td {
    border-bottom: none;
}

/* DataTables wrapper adjustments */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_length {
    padding: 10px 15px;
}

.dataTables_wrapper .dataTables_filter {
    padding: 10px 15px;
}

.dataTables_wrapper .dataTables_filter input {
    margin-left: 10px;
    padding: 5px 10px;
    border: 1px solid var(--dzcrud-border);
    border-radius: var(--dzcrud-radius);
}

.dataTables_wrapper .dataTables_info {
    padding: 10px 15px;

    color: var(--dzcrud-text-muted);
}

.dataTables_wrapper .dataTables_paginate {
    padding: 10px 15px;

}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0px 10px;
    margin: 0 2px;
    border: 1px solid var(--dzcrud-border);
    border-radius: var(--dzcrud-radius);
    background: white;
    color: var(--dzcrud-text);
    cursor: pointer;
    transition: var(--dzcrud-transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--dzcrud-primary);
    color: white;
    border-color: var(--dzcrud-primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--dzcrud-primary);
    color: white !important;
    border-color: var(--dzcrud-primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Action Buttons Styles
   ========================================================================== */

.dzcrud-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.dzcrud-action-btn {
    padding: 4px 8px;
    border: 1px solid var(--dzcrud-border);
    background: white;
    border-radius: var(--dzcrud-radius);
    cursor: pointer;
    transition: var(--dzcrud-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dzcrud-action-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.dzcrud-view-btn:hover {
    background: var(--dzcrud-info);
    color: white;
    border-color: var(--dzcrud-info);
}

.dzcrud-edit-btn:hover {
    background: var(--dzcrud-warning);
    color: white;
    border-color: var(--dzcrud-warning);
}

.dzcrud-delete-btn:hover {
    background: var(--dzcrud-danger);
    color: white;
    border-color: var(--dzcrud-danger);
}

.dzcrud-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   Modal Styles
   ========================================================================== */

.dzcrud-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

.dzcrud-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dzcrud-modal-overlay);
    animation: dzcrudFadeIn 0.2s ease;
}

.dzcrud-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--dzcrud-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: dzcrudSlideIn 0.3s ease;
}

.dzcrud-modal-header {
    padding: 15px 20px;
    background: var(--dzcrud-bg-light);
    border-bottom: 1px solid var(--dzcrud-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dzcrud-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--dzcrud-text);
}

.dzcrud-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dzcrud-text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--dzcrud-radius);
    transition: var(--dzcrud-transition);
}

.dzcrud-close:hover {
    background: var(--dzcrud-danger);
    color: white;
}

.dzcrud-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.dzcrud-modal-footer {
    padding: 15px 20px;
    background: var(--dzcrud-bg-light);
    border-top: 1px solid var(--dzcrud-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Modal open body class */
body.dzcrud-modal-open {
    overflow: hidden;
}

/* ==========================================================================
   Form Styles
   ========================================================================== */

.dzcrud-field-group {
    margin-bottom: 15px;
}

.dzcrud-field-group:last-child {
    margin-bottom: 0;
}

.dzcrud-field-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--dzcrud-text);
}

.dzcrud-field-label {
    font-weight: 600;
    color: var(--dzcrud-text);
    margin-bottom: 5px;
}

.dzcrud-field-value {
    color: var(--dzcrud-text);
    line-height: 1.6;
}

.dzcrud-field-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--dzcrud-border);
    border-radius: var(--dzcrud-radius);
    font-size: 14px;
    transition: var(--dzcrud-transition);
}

.dzcrud-field-input:focus {
    outline: none;
    border-color: var(--dzcrud-primary);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

textarea.dzcrud-field-input {
    min-height: 80px;
    resize: vertical;
}

select.dzcrud-field-input {
    cursor: pointer;
}

/* Field error states */
.dzcrud-field-error {
    border-color: var(--dzcrud-danger) !important;
}

.dzcrud-error-message {
    display: block;
    color: var(--dzcrud-danger);
    font-size: 12px;
    margin-top: 5px;
}

/* Character counter */
.dzcrud-char-counter {
    text-align: right;
    font-size: 12px;
    color: var(--dzcrud-text-muted);
    margin-top: 5px;
}

.dzcrud-char-counter-warning {
    color: var(--dzcrud-warning);
}

/* ==========================================================================
   View Content Styles
   ========================================================================== */

.dzcrud-view-content .dzcrud-field-group {
    padding: 10px 0;
    border-bottom: 1px solid var(--dzcrud-border);
}

.dzcrud-view-content .dzcrud-field-group:last-child {
    border-bottom: none;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.dzcrud-loading {
    text-align: center;
    padding: 40px;
    color: var(--dzcrud-text-muted);
}

.dzcrud-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--dzcrud-border);
    border-top-color: var(--dzcrud-primary);
    border-radius: 50%;
    animation: dzcrudSpin 1s linear infinite;
}

.dzcrud-spin {
    animation: dzcrudSpin 1s linear infinite;
}

/* ==========================================================================
   Notification Styles
   ========================================================================== */

.dzcrud-notification {
    position: fixed;
    top: 32px;
    right: 20px;
    max-width: 400px;
    padding: 15px 40px 15px 15px;
    border-radius: var(--dzcrud-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999999;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.dzcrud-notification-show {
    transform: translateX(0);
}

.dzcrud-notification-success {
    background: var(--dzcrud-success);
    color: white;
}

.dzcrud-notification-error {
    background: var(--dzcrud-danger);
    color: white;
}

.dzcrud-notification-info {
    background: var(--dzcrud-info);
    color: white;
}

.dzcrud-notification-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.dzcrud-notification-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Special Value Styles
   ========================================================================== */

.dzcrud-null {
    color: var(--dzcrud-text-muted);
    font-style: italic;
}

.dzcrud-empty {
    color: var(--dzcrud-text-muted);
}

.dzcrud-bool-true {
    color: var(--dzcrud-success);
}

.dzcrud-bool-false {
    color: var(--dzcrud-text-muted);
}

.dzcrud-json {
    background: var(--dzcrud-bg-light);
    padding: 10px;
    border-radius: var(--dzcrud-radius);
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media (max-width: 768px) {
    .dzcrud-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dzcrud-export-wrapper {
        text-align: left;
    }
    
    .dzcrud-modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .dzcrud-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: center;
    }
    
    .dataTables_wrapper .dataTables_filter {
        margin-top: 10px;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: center;
    }
    
    .dataTables_wrapper .dataTables_paginate {
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .dzcrud-table {
        font-size: 12px;
    }
    
    .dzcrud-table thead th,
    .dzcrud-table tbody td {
        padding: 8px 5px;
    }
    
    .dzcrud-actions {
        flex-direction: column;
    }
    
    .dzcrud-action-btn {
        width: 100%;
    }
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes dzcrudFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dzcrudSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes dzcrudSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   WordPress Admin Compatibility
   ========================================================================== */

.wp-admin .dzcrud-wrapper {
    margin: 20px 20px 20px 0;
}

.wp-admin .dzcrud-table {
    background: white;
}

/* Fix for WordPress admin z-index issues */
.wp-admin .dzcrud-modal {
    z-index: 100000;
}

.wp-admin .dzcrud-notification {
    z-index: 100001;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .dzcrud-toolbar,
    .dzcrud-actions,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        display: none !important;
    }
    
    .dzcrud-table {
        border: 1px solid #000;
    }
    
    .dzcrud-table th,
    .dzcrud-table td {
        border: 1px solid #000;
    }
}