/**
 * My Account - Container Management Styles
 */

/* Main wrapper */
.plm-my-containers {
    max-width: 100%;
    margin: 0;
}

.plm-my-containers h2 {
    font-size: 23px;
    font-weight: 400;
    margin: 0 0 20px;
    padding: 0;
    line-height: 1.3;
    color: #1d2327;
}

/* Container Grid */
.plm-containers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 0;
}

/* Container Card - WordPress Style */
.plm-container-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    margin: 0;
    padding: 0;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Ensure all container elements use border-box */
.plm-container-card *,
.plm-container-card *::before,
.plm-container-card *::after {
    box-sizing: border-box;
}

.plm-container-card:hover {
    border-color: #8c8f94;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

/* WordPress-style box header */
.container-header {
    background: #fff;
    border-bottom: 1px solid #c3c4c7;
    padding: 15px 20px;
    margin: 0;
}

/* Container body wrapper */
.container-body {
    position: relative;
}

/* Container content area */
.container-info {
    padding: 20px;
}

/* Contract info section */
.contract-info {
    background: #f6f7f7;
    border-top: 1px solid #c3c4c7;
    margin: 0;
    padding: 15px 20px;
}

/* Action buttons section */
.plm-action-buttons {
    background: #f6f7f7;
    border-top: 1px solid #c3c4c7;
    border-bottom: 1px solid #c3c4c7;
    padding: 12px 20px;
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Container actions section */
.container-actions {
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    background: #fff;
}

.container-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.container-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

/* Status Badge */
.container-status {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-running {
    background-color: #d7f7d7;
    color: #0a4b00;
}

.status-stopped {
    background-color: #fcf0f1;
    color: #8a0000;
}

/* Info rows */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f1;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #50575e;
    font-size: 13px;
}

.info-value {
    color: #2c3338;
    font-size: 13px;
    text-align: right;
}

/* Time remaining */
.time-remaining {
    margin-top: 10px;
    padding: 10px;
    background-color: #f0f8ff;
    border-radius: 3px;
    text-align: center;
    border: 1px solid #c3e1f7;
}

.time-remaining.expiring-soon {
    background-color: #fcf9e8;
    border-color: #f0c36d;
}

.countdown-label {
    display: block;
    font-size: 11px;
    color: #50575e;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.countdown-value {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2c3338;
}

.expiring-soon .countdown-value {
    color: #996800;
}

.plm-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #333;
}

.plm-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.plm-btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.plm-btn-icon .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 1;
    margin: 0;
}

/* Start button - Green */
.plm-btn[data-action="start"],
.plm-btn.plm-btn-success[data-action="start"] {
    background: #4caf50 !important;
    border-color: #4caf50 !important;
}

.plm-btn[data-action="start"]:hover,
.plm-btn.plm-btn-success[data-action="start"]:hover {
    background: #45a049 !important;
    border-color: #45a049 !important;
}

.plm-btn[data-action="start"] .dashicons,
.plm-btn.plm-btn-success[data-action="start"] .dashicons {
    color: white;
}

/* Stop button - Red */
.plm-btn[data-action="stop"] {
    background: #f44336 !important;
    border-color: #f44336 !important;
}

.plm-btn[data-action="stop"]:hover {
    background: #da190b !important;
    border-color: #da190b !important;
}

.plm-btn[data-action="stop"] .dashicons {
    color: white;
}

/* Restart button - Orange */
.plm-btn[data-action="restart"] {
    background: #ff9800;
    border-color: #ff9800;
}

.plm-btn[data-action="restart"]:hover {
    background: #e68900;
    border-color: #e68900;
}

.plm-btn[data-action="restart"] .dashicons {
    color: white;
}

/* Delete button - Dark Red */
.plm-btn-delete {
    background: #dc3545;
    border-color: #dc3545;
}

.plm-btn-delete:hover {
    background: #c82333;
    border-color: #c82333;
}

.plm-btn-delete .dashicons {
    color: white;
}

/* Refresh button - Green */
.plm-btn-success,
.refresh-single-container {
    background: #28a745;
    border-color: #28a745;
}

.plm-btn-success:hover,
.refresh-single-container:hover {
    background: #218838;
    border-color: #218838;
}

.plm-btn-success .dashicons,
.refresh-single-container .dashicons {
    color: white;
}

/* Container Actions - View Details and View Order buttons */
.container-actions .button {
    flex: 1;
    text-align: center;
    padding: 6px 12px;
    font-size: 13px;
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    color: #2c3338;
    text-decoration: none;
    transition: all 0.2s ease;
}

.container-actions .button:hover {
    background: #f0f0f1;
    border-color: #8c8f94;
    color: #135e96;
}

.container-actions .button:focus {
    border-color: #4f94d4;
    box-shadow: 0 0 0 1px #4f94d4;
    outline: 2px solid transparent;
}

/* Modal Styles */
.plm-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.plm-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.plm-modal-content h2 {
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
}

.plm-modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
    margin-top: -5px;
}

.plm-modal-close:hover,
.plm-modal-close:focus {
    color: #000;
}

/* Details Content */
.details-content {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.details-section {
    margin-bottom: 30px;
}

.details-section:last-child {
    margin-bottom: 0;
}

.details-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 8px;
}

.details-table {
    width: 100%;
    border-collapse: collapse;
}

.details-table th,
.details-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.details-table th {
    font-weight: 600;
    color: #666;
    width: 40%;
}

.details-table td {
    color: #333;
}

.details-table tr:last-child th,
.details-table tr:last-child td {
    border-bottom: none;
}

/* Status Badge in Details */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.status-running {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.status-stopped {
    background-color: #f8d7da;
    color: #721c24;
}

/* Subscription Status */
.subscription-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.subscription-status.status-active {
    background-color: #d4edda;
    color: #155724;
}

.subscription-status.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.subscription-status.status-cancelled,
.subscription-status.status-expired {
    background-color: #f8d7da;
    color: #721c24;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .plm-containers-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .plm-containers-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .plm-modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    .details-content {
        max-height: 85vh;
    }
    
    .details-table {
        font-size: 12px;
    }
    
    .details-table th {
        width: 40%;
    }
    
    .container-actions {
        flex-direction: column;
    }
    
    .container-actions .button {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .container-actions .button:last-child {
        margin-bottom: 0;
    }
    
    /* Smaller action buttons on mobile */
    .plm-btn-icon {
        width: 26px;
        height: 26px;
    }
    
    .plm-btn-icon .dashicons {
        font-size: 12px;
        width: 12px;
        height: 12px;
    }
    
    /* Adjust info rows for mobile */
    .info-row {
        font-size: 12px;
    }
    
    .container-header h3 {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    /* Container card adjustments */
    .plm-container-card {
        margin: 0;
    }
    
    /* Reduce padding on small screens */
    .container-info,
    .container-header,
    .container-actions,
    .plm-action-buttons,
    .contract-info {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Stack action buttons on very small screens */
    .plm-action-buttons {
        gap: 8px;
    }
    
    /* Make container action buttons full width */
    .container-actions {
        flex-wrap: wrap;
    }
    
    .container-actions .button {
        flex: 1 1 100%;
    }
    
    /* Password field adjustments for mobile */
    .password-field {
        flex-wrap: wrap;
    }
    
    .password-input {
        flex: 1 1 100%;
        margin-bottom: 5px;
    }
    
    .password-field .button-small {
        flex: 1;
    }
}

/* Loading State */
.plm-loading {
    text-align: center;
    padding: 40px;
}

.plm-loading:after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.woocommerce-message--info {
    background-color: #f0f8ff;
    border-left: 4px solid #007cba;
    padding: 15px;
    margin: 20px 0;
}

/* Spinning animation for loading */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.dashicons.spinning {
    animation: spin 1s linear infinite;
}

/* Search input */
.plm-search-input {
    width: 100%;
    max-width: 600px;
    padding: 8px 12px;
    margin: 0 0 20px 0;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    background-color: #fff;
    color: #2c3338;
    box-shadow: 0 0 0 transparent;
    transition: border-color 0.1s linear;
    box-sizing: border-box;
}

.plm-search-input:focus {
    border-color: #4f94d4;
    box-shadow: 0 0 0 1px #4f94d4;
    outline: 2px solid transparent;
}

/* Search input wrapper for better control */
.plm-search-wrapper {
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .plm-search-input {
        max-width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    .plm-search-input {
        padding: 10px 12px;
        margin-bottom: 15px;
    }
}

/* Make info values clickable when they're copyable */
.info-value[title="Click to copy"],
.copyable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.info-value[title="Click to copy"]:hover,
.copyable:hover {
    color: #135e96;
}

/* Password field styling */
.password-field {
    display: flex;
    align-items: center;
    gap: 5px;
}

.password-input {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background-color: #f6f7f7;
    font-family: monospace;
    font-size: 13px;
    color: #2c3338;
}

.password-field .button-small {
    padding: 4px 8px;
    min-height: 28px;
    line-height: 1;
    font-size: 12px;
}

.password-field .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* No results message */
.plm-no-results {
    text-align: center;
    padding: 20px;
    margin: 20px 0;
    background-color: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    color: #50575e;
}

/* Search input placeholder */
.plm-search-input::placeholder {
    color: #8c8f94;
    opacity: 1;
}

.plm-search-input::-webkit-input-placeholder {
    color: #8c8f94;
}

.plm-search-input::-moz-placeholder {
    color: #8c8f94;
    opacity: 1;
}

.plm-search-input:-ms-input-placeholder {
    color: #8c8f94;
}

/* Loading overlay styles */
.plm-loading-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.plm-loading-content {
    text-align: center !important;
    padding: 30px !important;
    background-color: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    border: 1px solid #ddd !important;
    max-width: 300px !important;
}

.plm-loading-content .dashicons {
    font-size: 48px !important;
    color: #0073aa !important;
    margin-bottom: 15px !important;
    display: block !important;
}

.plm-loading-content p {
    margin: 0 !important;
    font-size: 16px !important;
    color: #333 !important;
    font-weight: 500 !important;
}

/* Enhanced spinning animation */
.plm-loading-content .spinning {
    animation: plm-spin 1s linear infinite !important;
}

@keyframes plm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}